Closed kaptinlin closed 5 months ago
In both of the tests you reference, one of the $anchor
keywords has a different base URI, provided by an adjacent $id
keyword.
These aren't duplicate anchors, just same-named anchors in different resources.
Truly duplicate $anchor
s should ("MAY") be an error.
At the end of Core 8.2.2:
The effect of specifying the same fragment name multiple times within the same resource, using any combination of "$anchor" and/or "$dynamicAnchor", is undefined. Implementations MAY raise an error if such usage is detected.
thanks
Description: There seems to be a discrepancy in how duplicate
$anchor
definitions are handled across different tests in the JSON Schema Test Suite. Specifically, the tests present conflicting interpretations of whether a subsequent$anchor
with the same name should override an earlier definition or whether the first occurrence should be retained.Relevant Test Files and Observations:
Ref Test (ref.json#L632) - In this test, when
$anchor
is defined multiple times, the reference points to the first occurrence of the$anchor
.Anchor Test (anchor.json#L84) - This test appears to indicate that the latest
$anchor
definition overrides earlier ones.Concern: The handling of duplicate
$anchor
names varies between tests, which may lead to inconsistent behavior in schema processing across different implementations. This inconsistency could impact the predictability and reliability of JSON Schema validation.Questions and Suggested Actions:
$anchor
names should be handled? Specifically, should a later$anchor
override an earlier one, or should the first defined$anchor
be the one that is referenced?$anchor
names consistently.$anchors
.Thank you for considering this issue. Addressing this ambiguity will help in enhancing the robustness and interoperability of JSON Schema implementations and tools.