Skip to content

Fix OAS 3.1 schema resolution in ResolverFully - #2404

Open
ib-fsrnec wants to merge 1 commit into
swagger-api:masterfrom
ib-fsrnec:bug/2403-fix-oas-31-resolution
Open

ib-fsrnec wants to merge 1 commit into
swagger-api:masterfrom
ib-fsrnec:bug/2403-fix-oas-31-resolution

Conversation

@ib-fsrnec

Copy link
Copy Markdown

Description

ResolverFully currently relies on OAS 3.0 shape-specific schema subclasses such as ComposedSchema, ArraySchema, and MapSchema. OAS 3.1 schemas are deserialized as JsonSchema, so combinators and nested schema-valued keywords can be skipped during resolution.

This PR:

  • Processes allOf, oneOf, and anyOf through the base Schema model so they also work for OAS 3.1.
  • Recursively resolves OAS 3.1 schema-valued keywords, including:
    • items
    • additionalProperties
    • prefixItems
    • patternProperties
    • contains
    • contentSchema
    • propertyNames
    • unevaluatedProperties
    • unevaluatedItems
    • if, then, and else
    • dependentSchemas
  • Adds shared not traversal for both OAS 3.0 and OAS 3.1.
  • Avoids early returns when multiple OAS 3.1 keywords are present on the same JsonSchema.
  • Preserves the existing OAS 3.0 combinator aggregation behavior.

The implementation intentionally keeps the change surface as small as possible. The dereferencing logic can be simplified and refactored in a follow-up phase now that OAS 3.1 schema handling is covered explicitly.

Regression tests cover request-body and response schemas, nested combinators, references, OAS 3.0 compatibility, and schemas containing both array- and object-specific keywords.

Known limitations are clearly identified and can be continuously mitigated through future changes. In particular, combinator aggregation retains an existing limitation: flattening arbitrary combinators into a new schema is not fully lossless and may drop sibling constraints or alter oneOf/anyOf semantics. This limitation is documented for follow-up work. Parsed additionalItems is also documented separately because the current deserializer stores it as an extension rather than populating Schema.additionalItems.

Fixes issue #2403.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and the focused regression tests pass locally
  • I have linked related issues (if any)

Process OAS 3.1 combinators through the base Schema model and recursively
resolve schema-valued keywords, including nested items, additionalProperties,
not, if/then/else, contains, prefixItems, propertyNames, and dependentSchemas.

Preserve existing OAS 3.0 combinator behavior and add regression coverage for
request and response schemas, nested combinators, references, and mixed
array/object keywords. Document the parsed-input limitation for additionalItems
and the existing limitations of combinator aggregation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant