Recognize OpenAPI 3.2.x version strings, routed through the 3.1 model path - #2401
Open
khayashi4337 wants to merge 1 commit into
Open
khayashi4337 wants to merge 1 commit into
khayashi4337 wants to merge 1 commit into
Conversation
… path OpenAPI 3.2 builds on the 3.1 data model, so 3.2 documents are now accepted wherever the 3.1-family code path is selected: - OpenAPIDeserializer.parseRoot accepts "3.2" (loose prefix, matching the existing convention for "3.0"/"3.1") and sets the openapi31 flag - the dotted-form warning check gains "3.2." so a bare "3.2" is accepted but reported as not a valid version field, same as bare "3.0"/"3.1" - OpenAPIV3Parser.resolve and OpenAPIDereferencer31.canDereference route 3.2 documents through the 3.1 dereferencer - ResolverCache treats 3.2 as openapi31 so the 3.1 (JSON Schema 2020-12) Jackson mapper is selected for external-ref deserialization. This is load-bearing only for direct OpenAPIResolver callers (public API): the internal resolve() path routes 3.1/3.2 through OpenAPIDereferencer31 and never constructs a ResolverCache for them - canDereference gains a null guard on getOpenapi() The openapi31 flag's meaning is widened from "3.1" to "3.1-family or later". This is a stopgap: swagger-core's SpecVersion enum already exists (V30/V31 today); once it gains a V32 value (swagger-core PR #5254/#5255 direction), this flag should be replaced with that. 3.2-only members (query operation, additionalOperations, $self, in: querystring parameters) are reported as "attribute ... is unexpected" / "is not of type" validation messages but are not reproduced in the parsed model, so resolved output can differ from a fully 3.2-aware parser. README notes the experimental handling. Tests: OAI32DeserializationTest covers 3.2.0/3.2.1 parsing, unexpected-attribute recording for 3.2-only fields, resolveFully actually resolving refs, routing through the 3.1 dereferencer via components.pathItems, bare "3.2" acceptance-with-warning, loose-prefix "3.20.0" acceptance-with-warning (a prefix-match artifact, not true 3.x support), 3.3.0 genuinely rejected (contrast with the 3.20.0 case), and malformed "3.2." -- which parses without a warning, an inherited quirk of the pre-existing convention that this change extends rather than fixes, asserted explicitly so it doesn't silently drift if the 3.0/3.1 behavior changes later. Reviewed by Codex and Fable (3 rounds each: initial, post-rebase, and this follow-up); this revision addresses all rounds' findings.
This was referenced Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Thank you for contributing to swagger-parser!
Please fill out the following checklist to help us review your PR efficiently.
Description
OpenAPI 3.2 builds on the 3.1 data model. This PR makes swagger-parser recognize
"openapi": "3.2.x"version strings and route them through the existing 3.1-familycode path (deserializer, resolver/dereferencer), instead of rejecting them outright.
This is a narrow, incremental step toward #2248, not a full 3.2 implementation:
queryoperation,additionalOperations,$self,in: querystringparameters) are still reported asattribute ... is unexpected/is not of typevalidation messages and are not reproduced in the parsedmodel, so resolved output can differ from a fully 3.2-aware parser. Full support
needs the model changes proposed in feat: support the OpenAPI 3.2 QUERY method in PathItem and the JAX-RS reader swagger-core#5253 (currently
awaiting design-question answers from the 2026-07-23 comment on [Feature]: Support for OpenAPI Spec 3.2 #2248) plus a
SpecVersion.V32value -- this change's widening of theopenapi31flag'smeaning ("3.1-family or later") is a stopgap for that.
$dynamicRef/$dynamicAnchor) is out of scopehere, consistent with the note on [Feature]: Support for OpenAPI Spec 3.2 #2248 that it was the one gap left in both
reference implementations (scalar's TypeScript PR and Microsoft OpenAPI.NET's
PR, both linked from that issue).
What this PR actually changes:
OpenAPIDeserializer.parseRootaccepts"3.2"as a loose prefix (matching theexisting convention for
"3.0"/"3.1") and sets theopenapi31flag"3.2."so a bare"3.2"is accepted butreported as not a valid version field, same as bare
"3.0"/"3.1"OpenAPIV3Parser.resolveandOpenAPIDereferencer31.canDereferenceroute 3.2documents through the 3.1 dereferencer
ResolverCachetreats 3.2 asopenapi31so the 3.1 (JSON Schema 2020-12)Jackson mapper is selected for external-ref deserialization. This is
load-bearing only for direct
OpenAPIResolvercallers (public API): theinternal
resolve()path routes 3.1/3.2 throughOpenAPIDereferencer31andnever constructs a
ResolverCachefor themcanDereferencegains a null guard ongetOpenapi()Tests:
OAI32DeserializationTest(10 cases) covers 3.2.0/3.2.1 parsing,unexpected-attribute recording for 3.2-only fields,
resolveFullyactuallyresolving refs, routing through the 3.1 dereferencer via
components.pathItems,bare
"3.2"acceptance-with-warning, loose-prefix"3.20.0"acceptance-with-warning(a prefix-match artifact, not true 3.x support),
3.3.0genuinely rejected(contrast with the
3.20.0case), and malformed"3.2."-- which parses without awarning, an inherited quirk of the pre-existing convention that this change extends
rather than fixes, asserted explicitly so it doesn't silently drift later.
Relates to: #2248 (does not fully close it -- see scope note above)
Type of Change
Checklist
Screenshots / Additional Context
No UI change. Full local
mvn testrun: 706 tests inswagger-parser-v3, 78 inswagger-parser-v2-converter, 47 inswagger-parser-safe-url-resolver-- allpassing, zero failures.
🤖 Generated with Claude Code