oas3-rs icon indicating copy to clipboard operation
oas3-rs copied to clipboard

Support boolean schemas in OpenAPI 3.1 properties and composition keywords

Open tarnishablec opened this issue 3 weeks ago • 0 comments

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, and properties in ObjectSchema to use Schema instead of ObjectOrReference<ObjectSchema>.
  • Added a Schema::resolve method to facilitate resolving schemas, including handling boolean schemas by returning an empty ObjectSchema.

Test coverage for boolean schemas

  • Enhanced tests to verify correct parsing and serialization of boolean schemas in properties, allOf, anyOf, oneOf, and prefixItems, 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 Schema variants.

tarnishablec avatar Nov 23 '25 05:11 tarnishablec