From 29f4a121c1207b3134289c0b2f2a9f90be702364 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Sat, 13 Aug 2022 16:12:13 -0700 Subject: [PATCH 1/4] Disallow "#" as an $id. In a document root schema, "$id": "#" is a no-op, and in an embedded schema resource root, it results in the embeddded resource having the same URI as its context resource. Given that the specificaiton says implementations SHOULD raise an error for duplicate IRIs, there is no reason to allow this form. --- jsonschema-core.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 5343194f..5b1153ad 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1353,8 +1353,8 @@ If present, the value for this keyword MUST be a string, and MUST represent a - valid IRI-reference. This IRI-reference - SHOULD be normalized, and MUST resolve to an + valid IRI-reference with a non-empty non-fragment + component. This IRI-reference SHOULD be normalized, and MUST resolve to an absolute-IRI (without a fragment), or to a IRI with an empty fragment. From bdbf918ee8a061523189d9061c8b0234756c7cdf Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Sat, 13 Aug 2022 16:24:08 -0700 Subject: [PATCH 2/4] Consolidate and clarify duplicate IRI behavior --- jsonschema-core.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 5b1153ad..9a79eb25 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1456,11 +1456,16 @@ fragment "#foo" when used in a IRI. See below for full examples. + + +
- 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. + A schema MAY (and likely will) have multiple IRIs, but there is no way + for an IRI to identify more than one schema. When multiple schemas + attempt to identify as the same IRI through the use of "$id", "$anchor", + "$dynamicAnchor", or any other mechanism, implementations SHOULD raise + an error condition. Otherwise the result is undefined, and even if + documented will not be interoperable.
@@ -1671,11 +1676,6 @@ be noted within a schema document as it is processed, producing associations as shown in appendix . - - A schema MAY (and likely will) have multiple IRIs, but there is no way for a - IRI to identify more than one schema. When multiple schemas try to identify - as the same IRI, validators SHOULD raise an error condition. -
From 170ba3b65e2bd76201725bfff5268fb7edbd543e Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Sat, 13 Aug 2022 16:37:26 -0700 Subject: [PATCH 3/4] Note that empty fragments produce duplicates --- jsonschema-core.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 9a79eb25..c5438b38 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1467,6 +1467,11 @@ an error condition. Otherwise the result is undefined, and even if documented will not be interoperable. + + Note that due to the semantics of JSON Pointer fragments, schema IRIs + that differ only by the presence or absence of an empty fragment MUST + be considered duplicates. +
From 853c82bd9e4a1a33fa28950e977a2ab8bd6144d4 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Sun, 21 Aug 2022 14:07:14 -0700 Subject: [PATCH 4/4] Don't forbid cases already noted as errors But do highlight that they are errors in the section where that is likely to be the most relevant. --- jsonschema-core.xml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index c5438b38..dfdafe13 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1353,8 +1353,8 @@ If present, the value for this keyword MUST be a string, and MUST represent a - valid IRI-reference with a non-empty non-fragment - component. This IRI-reference SHOULD be normalized, and MUST resolve to an + valid IRI-reference. This IRI-reference + SHOULD be normalized, and MUST resolve to an absolute-IRI (without a fragment), or to a IRI with an empty fragment. @@ -1392,7 +1392,10 @@ RFC 3986 section 5.1.2 regarding encapsulating entities, if an "$id" in a subschema is a relative IRI-reference, the base IRI for resolving that reference is the IRI of - the parent schema resource. + the parent schema resource. Note that an "$id" consisting of an empty IRI or + of the empty fragment only will result in the embedded resource having + the same IRI as the encapsulating resource, which SHOULD be considered + an error per section . If no parent schema object explicitly identifies itself as a resource @@ -1458,7 +1461,7 @@
-
+
A schema MAY (and likely will) have multiple IRIs, but there is no way for an IRI to identify more than one schema. When multiple schemas