oas3-rs
oas3-rs copied to clipboard
Support boolean schemas in OpenAPI 3.1 properties and composition keywords
This pull request refactors the ObjectSchema struct to use the more general Schema type for several fields, allowing support for boolean schemas (true/false) in places like properties, allOf, anyOf, oneOf, and prefixItems. It also introduces comprehensive tests to ensure boolean schemas are handled correctly in both YAML and JSON formats, and adds a helper for resolving schemas. These changes address issue #278 and improve OpenAPI/JSON Schema compatibility.
Schema structure improvements
- Updated the fields
all_of,any_of,one_of,prefix_items, andpropertiesinObjectSchemato useSchemainstead ofObjectOrReference<ObjectSchema>. - Added a
Schema::resolvemethod to facilitate resolving schemas, including handling boolean schemas by returning an emptyObjectSchema.
Test coverage for boolean schemas
- Enhanced tests to verify correct parsing and serialization of boolean schemas in
properties,allOf,anyOf,oneOf, andprefixItems, including round-trip checks for YAML and JSON. - Updated existing tests to match the new structure, ensuring that references and inline schemas are correctly identified as
Schemavariants.