Detect $dynamicAnchor in OpenAPI 3.0 documents (DynamicAnchorIn30 rule) - #205
Open
takayamaki wants to merge 4 commits into
Open
Detect $dynamicAnchor in OpenAPI 3.0 documents (DynamicAnchorIn30 rule)#205takayamaki wants to merge 4 commits into
takayamaki wants to merge 4 commits into
Conversation
Closes the 3.1 divergence enumeration. Matching pattern to $dynamicRef: raw_schema key detection, 3.0 only emits, parse stays permissive.
$dynamicAnchor on a 3.0 document warns and raises (JSON Schema 2020-12 dynamic resolution point with no 3.0 equivalent); the same keyword on a 3.1 document stays clean.
takayamaki
marked this pull request as ready for review
August 27, 2026 23:57
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.
Continuing the OpenAPI 3.1 work from #152.
$dynamicAnchoris the companion of$dynamicReffrom #203.$dynamicRefnames an anchor to resolve against the dynamic scope,and
$dynamicAnchoris what declares such an anchor on a schema.3.0 knows neither: its only referencing keyword is
$ref, resolved statically.This PR adds detection of that version mismatch.
A 3.0 document using
$dynamicAnchoris relying on a keyword its declared version does not define,and
SpecValidatorshould be able to say so.SpecValidator rule
DynamicAnchorIn30reports a violation for each schema in a 3.0 document that uses$dynamicAnchor:Detection inspects
raw_schemakey presence,so it fires whether or not anything references the anchor.
As with #203, this PR does not make
$dynamicAnchortake part in reference resolution.Dynamic resolution has to pick its target while the schema is being evaluated,
which likely means redesigning
SchemaValidatorin this gem.Resolving it is a TODO beyond this series of PRs.