Implement 2020-12 $dynamicRef dynamic scope semantics - #159
Open
jnbdz wants to merge 2 commits into
Open
Conversation
The $dynamicRef implementation resolved through the first encountered $dynamicAnchor with the same name, which diverges from the 2020-12 specification in three ways: anchors pushed into the dynamic context were not popped on the early-return paths, so schemas from left scopes stayed resolvable; a $dynamicRef without a matching $dynamicAnchor was silently ignored instead of behaving like a normal $ref; and resolution only considered anchors whose subschema had been visited instead of resources entered by evaluation. Track the dynamic scope (entered schema resources and anchors) in a validate wrapper that pops in a finally block, and resolve $dynamicRef per specification: initial resolution like $ref, then, only when the target carries a matching $dynamicAnchor, re-resolution to the first resource in the dynamic scope defining that anchor. Anchors registered under their parent resource uri during dereferencing are excluded by an ownership check. The legacy behavior is preserved for draft-4/7. Un-skips the seven core draft2020-12/dynamicRef TCK tests listed as unsupported since 2022. Fixes eclipse-vertx#158
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.
Fixes #158
Motivation
Seven core
draft2020-12/dynamicReftests from the official test suite have been skipped viaunsupported-tck-tests.propertiessince 2022. Unlike the rest of that file (genuinely optional features), they mask three real conformance gaps in$dynamicRef:$dynamicRefwith no matching$dynamicAnchor(e.g. targeting a plain$anchor) was silently ignored instead of behaving like a normal$ref;$dynamicAnchor.Changes
validateis now a thin wrapper that tracks the dynamic scope — entered schema resources and$dynamicAnchors — and pops it in afinally, so every return path leaves scope correctly.$dynamicRef(2019-09/2020-12 path) resolves per spec: initial resolution like$ref(unresolvable →SchemaException); only when the initial target carries a matching$dynamicAnchoris it re-resolved to the first (outermost) resource in the dynamic scope defining that anchor. An ownership check excludes anchor lookup entries registered under the parent resource URI during dereferencing.draft2020-12/dynamicRefentries are removed fromunsupported-tck-tests.properties— the whole TCK now runs them and passes.Full suite: 4797 tests, 0 failures (skips down from 152 to 145).