@@ -452,8 +452,8 @@ The lexical scope of a keyword is determined by the nested JSON data structure
452
452
of objects and arrays. The largest such scope is an entire schema document. The
453
453
smallest scope is a single schema object with no subschemas.
454
454
455
- Keywords MAY be defined with a partial value, such as a IRI- reference, which
456
- must be resolved against another value, such as another IRI- reference or a full
455
+ Keywords MAY be defined with a partial value, such as a IRI reference, which
456
+ must be resolved against another value, such as another IRI reference or a full
457
457
IRI, which is found through the lexical structure of the JSON document. The
458
458
` $id ` , ` $ref ` , and ` $dynamicRef ` core keywords, and the "base" JSON Hyper-Schema
459
459
keyword, are examples of this sort of behavior.
@@ -542,7 +542,7 @@ Identifiers define IRIs for a schema, or affect how such IRIs are resolved in
542
542
keywords, most notably ` $id ` .
543
543
544
544
Canonical schema IRIs MUST NOT change while processing an instance, but keywords
545
- that affect IRI- reference resolution MAY have behavior that is only fully
545
+ that affect IRI reference resolution MAY have behavior that is only fully
546
546
determined at runtime.
547
547
548
548
While custom identifier keywords are possible, extension designers should take
@@ -894,50 +894,45 @@ by other parties.
894
894
895
895
### Base IRI, Anchors, and Dereferencing
896
896
897
- To differentiate between schemas in a vast ecosystem, schemas are identified by
898
- [ IRI] ( #rfc3987 ) , and can embed references to other schemas by specifying their
899
- IRI.
897
+ To differentiate between schemas in a vast ecosystem, schema resources are
898
+ identified by [ absolute IRIs] ( #rfc3987 ) (without fragments). These identifiers
899
+ are used to create references between schema resources. When comparing IRIs for
900
+ the purposes of resource identification, implementations SHOULD first follow the
901
+ IRI normalization procedures defined in [ RFC 3987] ( #rfc3987 ) , section 5.3.
900
902
901
- Several keywords can accept a relative [ IRI- reference] ( #rfc3987 ) , or a value
902
- used to construct a relative IRI- reference. For these keywords, it is necessary
903
+ Several keywords can accept a relative [ IRI reference] ( #rfc3987 ) , or a value
904
+ used to construct a relative IRI reference. For these keywords, it is necessary
903
905
to establish a base IRI in order to resolve the reference.
904
906
905
907
#### The ` $id ` Keyword {#id-keyword}
906
908
907
- The ` $id ` keyword identifies a schema resource with its [ canonical] ( #rfc6596 )
908
- IRI.
909
+ An ` $id ` keyword in a schema or subschema identifies that schema or subschema as
910
+ a distinct schema resource. The value for this keyword MUST be a string, and
911
+ MUST represent a valid [ IRI reference] ( #rfc3987 ) without a fragment.
912
+
913
+ When the value of this keyword is resolved against the current base IRI, the
914
+ resulting absolute IRI then serves as the identifier for the schema resource and
915
+ as a base IRI for relative IRI references in keywords within that schema
916
+ resource and for embedded schema resources, in accordance with [ RFC 3987 section
917
+ 6.5] ( #rfc3987 ) and [ RFC 3986 section 5.1.1] ( #rfc3986 ) regarding base IRIs
918
+ embedded in content and RFC 3986 section 5.1.2 regarding encapsulating entities.
909
919
910
920
Note that this IRI is an identifier and not necessarily a network locator. In
911
921
the case of a network-addressable URL, a schema need not be downloadable from
912
922
its canonical IRI.
913
923
914
- If present, the value for this keyword MUST be a string, and MUST represent a
915
- valid [ IRI-reference] ( #rfc3987 ) . This IRI-reference SHOULD be normalized, and
916
- MUST resolve to an [ absolute-IRI] ( #rfc3987 ) (without a fragment).
917
-
918
- The resulting absolute-IRI serves as the base IRI for relative IRI-references in
919
- keywords within the schema resource, in accordance with [ RFC 3987 section
920
- 6.5] ( #rfc3987 ) and [ RFC 3986 section 5.1.1] ( #rfc3986 ) regarding base IRIs
921
- embedded in content.
922
-
923
- The presence of ` $id ` in a subschema indicates that the subschema constitutes a
924
- distinct schema resource within a single schema document. Furthermore, in
925
- accordance with [ RFC 3987 section 6.5] ( #rfc3987 ) and [ RFC 3986 section
926
- 5.1.2] ( #rfc3986 ) regarding encapsulating entities, if an ` $id ` in a subschema is
927
- a relative IRI-reference, the base IRI for resolving that reference is the IRI
928
- of the parent schema resource. Note that an ` $id ` consisting of an empty IRI or
929
- of the empty fragment only will result in the embedded resource having the same
930
- IRI as the encapsulating resource, which SHOULD be considered an error per
931
- {{duplicate-iris}}.
924
+ Also note that an ` $id ` consisting of an empty IRI only will result in the
925
+ embedded resource having the same IRI as the encapsulating resource, which
926
+ SHOULD be considered an error per {{duplicate-iris}}.
932
927
933
928
If no parent schema object explicitly identifies itself as a resource with
934
929
` $id ` , the base IRI is that of the entire document, as established by the steps
935
- given in the [ previous section. ] ( initial-base )
930
+ given in {{ initial-base}}.
936
931
937
932
##### Identifying the root schema
938
933
939
934
The root schema of a JSON Schema document SHOULD contain an ` $id ` keyword with
940
- an [ absolute- IRI] ( #rfc3987 ) (containing a scheme, but no fragment).
935
+ an [ absolute IRI] ( #rfc3987 ) (containing a scheme, but no fragment).
941
936
942
937
#### Defining location-independent identifiers {#anchors}
943
938
@@ -971,7 +966,7 @@ If present, the value of these keywords MUST be a string and MUST conform to the
971
966
plain name fragment identifier syntax defined in {{fragments}}.[ ^ 4 ]
972
967
973
968
[ ^ 4 ] : Note that the anchor string does not include the "#" character, as it is
974
- not a IRI- reference. An ` $anchor ` : "foo" becomes the fragment ` #foo ` when used
969
+ not a IRI reference. An ` $anchor ` : "foo" becomes the fragment ` #foo ` when used
975
970
in a IRI. See below for full examples.
976
971
977
972
#### Duplicate schema identifiers {#duplicate-iris}
@@ -1005,7 +1000,7 @@ identified schema. Its results are the results of the referenced schema.[^5]
1005
1000
[ ^ 5 ] : Note that this definition of how the results are determined means that
1006
1001
other keywords can appear alongside of ` $ref ` in the same schema object.
1007
1002
1008
- The value of the ` $ref ` keyword MUST be a string which is a IRI-Reference .
1003
+ The value of the ` $ref ` keyword MUST be a string which is a IRI reference .
1009
1004
Resolved against the current IRI base, it produces the IRI of the schema to
1010
1005
apply. This resolution is safe to perform on schema load, as the process of
1011
1006
evaluating an instance cannot change how the reference resolves.
@@ -1022,7 +1017,7 @@ reference themselves). The extension point is defined with `$dynamicAnchor` and
1022
1017
only exhibits runtime dynamic behavior when referenced with ` $dynamicRef ` .
1023
1018
1024
1019
The value of the ` $dynamicRef ` property MUST be a string which is a
1025
- IRI-Reference that contains a valid [ plain name fragment] ( #anchors ) . Resolved
1020
+ IRI reference that contains a valid [ plain name fragment] ( #anchors ) . Resolved
1026
1021
against the current IRI base, it indicates the schema resource used as the
1027
1022
starting point for runtime resolution. This initial resolution is safe to
1028
1023
perform on schema load.
@@ -1190,15 +1185,9 @@ automatically.
1190
1185
1191
1186
When an implementation encounters the reference to "other.json", it resolves
1192
1187
this to ` https://example.net/other.json ` , which is not defined in this document.
1193
- If a schema with that identifier has otherwise been supplied to the
1194
- implementation, it can also be used automatically.[ ^ 7 ]
1195
-
1196
- [ ^ 7 ] : What should implementations do when the referenced schema is not known?
1197
- Are there circumstances in which automatic network dereferencing is allowed? A
1198
- same origin policy? A user-configurable option? In the case of an evolving API
1199
- described by Hyper-Schema, it is expected that new schemas will be added to the
1200
- system dynamically, so placing an absolute requirement of pre-loading schema
1201
- documents is not feasible.
1188
+ If an implementation has been configured to resolve that identifier to a schema
1189
+ via pre-loading or other means, it can be used automatically; otherwise, the
1190
+ behavior described in {{failed-refs}} MUST be used.
1202
1191
1203
1192
#### JSON Pointer fragments and embedded schema resources {#embedded}
1204
1193
@@ -1271,10 +1260,10 @@ the `$id` of the embedded or referenced resource unless it is specifically
1271
1260
desired to identify the object containing the ` $ref ` in the second
1272
1261
(non-embedded) arrangement.
1273
1262
1274
- An implementation MAY choose not to support addressing schema resource contents
1275
- by IRIs using a base other than the resource's canonical IRI, plus a JSON
1276
- Pointer fragment relative to that base. Therefore, schema authors SHOULD NOT
1277
- rely on such IRIs, as using them may reduce interoperability.[ ^ 8 ]
1263
+ Due to the potential break in functionality described above, the behavior for
1264
+ using JSON Pointer fragments that point to or cross a resource boundary is
1265
+ undefined. Schema authors SHOULD NOT rely on such IRIs, as using them may
1266
+ reduce interoperability.[ ^ 8 ]
1278
1267
1279
1268
[ ^ 8 ] : This is to avoid requiring implementations to keep track of a whole stack
1280
1269
of possible base IRIs and JSON Pointer fragments for each, given that all but
@@ -1318,7 +1307,7 @@ When the Schema Resource referenced by a by-reference applicator is bundled, it
1318
1307
is RECOMMENDED that the Schema Resource be located as a value of a ` $defs `
1319
1308
object at the containing schema's root. The key of the ` $defs ` for the now
1320
1309
embedded Schema Resource MAY be the ` $id ` of the bundled schema or some other
1321
- form of application defined unique identifer (such as a UUID). This key is not
1310
+ form of application defined unique identifier (such as a UUID). This key is not
1322
1311
intended to be referenced in JSON Schema, but may be used by an application to
1323
1312
aid the bundling process.
1324
1313
@@ -1381,18 +1370,15 @@ recursive nesting like this; the behavior is undefined.
1381
1370
#### References to Possible Non-Schemas {#non-schemas}
1382
1371
1383
1372
Subschema objects (or booleans) are recognized by their use with known
1384
- applicator keywords or with location-reserving keywords such as
1385
- [ ` $defs ` ] ( #defs ) that take one or more subschemas as a value. These keywords may
1386
- be ` $defs ` and the standard applicators from this document or
1387
- implementation-specific custom keywords.
1388
-
1389
- Multi-level structures of unknown keywords are capable of introducing nested
1390
- subschemas, which would be subject to the processing rules for ` $id ` . Therefore,
1391
- having a reference target in such an unrecognized structure cannot be reliably
1392
- implemented, and the resulting behavior is undefined. Similarly, a reference
1393
- target under a known keyword, for which the value is known not to be a schema,
1394
- results in undefined behavior in order to avoid burdening implementations with
1395
- the need to detect such targets.[ ^ 10 ]
1373
+ applicator keywords or with location-reserving keywords, such as
1374
+ [ ` $defs ` ] ( #defs ) , that take one or more subschemas as a value. These keywords
1375
+ include the standard applicators from this document or implementation-specific
1376
+ custom keywords.
1377
+
1378
+ A reference target under a keyword for which the value is not explicitly known
1379
+ to be a schema results in undefined behavior. Implementations MAY support
1380
+ references to these locations, however such behavior is not considered
1381
+ interoperable and should not be relied upon.[ ^ 10 ]
1396
1382
1397
1383
[ ^ 10 ] : These scenarios are analogous to fetching a schema over HTTP but
1398
1384
receiving a response with a Content-Type other than ` application/schema+json ` .
@@ -1401,13 +1387,7 @@ server offered no guarantee that it actually is any such thing. Therefore,
1401
1387
interpreting it as such has security implication and may produce unpredictable
1402
1388
results.
1403
1389
1404
- Note that single-level custom keywords with identical syntax and semantics to
1405
- ` $defs ` do not allow for any intervening ` $id ` keywords, and therefore will
1406
- behave correctly under implementations that attempt to use any reference target
1407
- as a schema. However, this behavior is implementation-specific and MUST NOT be
1408
- relied upon for interoperability.
1409
-
1410
- #### Failure to resolve references
1390
+ #### Failure to resolve references {#failed-refs}
1411
1391
1412
1392
If for any reason a reference cannot be resolved, the evaluation MUST halt and
1413
1393
return an indeterminant result. Specifically, it MUST NOT return a passing or
@@ -2214,56 +2194,79 @@ name fragment identifiers.
2214
2194
}
2215
2195
```
2216
2196
2217
- The schemas at the following IRI-encoded [ JSON Pointers] ( #rfc6901 ) (relative to
2218
- the root schema) have the following base IRIs, and are identifiable by any
2219
- listed IRI in accordance with {{fragments}} and {{embedded}} above.
2197
+ The schemas at the following locations (indicated by plain
2198
+ [ JSON Pointers] ( #rfc6901 ) relative to the root document) have the following base
2199
+ IRIs, and are identifiable by any listed IRI in accordance with {{fragments}}
2200
+ and {{embedded}} above.
2220
2201
2221
- ` # ` (document root): canonical (and base) IRI: ` https://example.com/root.json `
2202
+ Document root:
2203
+ - canonical (and base) IRI: ` https://example.com/root.json `
2222
2204
- canonical resource IRI plus pointer fragment: ` https://example.com/root.json# `
2223
2205
2224
- ` #/$defs/A ` : base IRI: ` https://example.com/root.json `
2206
+ Document location ` /$defs/A ` :
2207
+ - base IRI: ` https://example.com/root.json `
2225
2208
- canonical resource IRI plus plain fragment:
2226
2209
` https://example.com/root.json#foo `
2227
2210
- canonical resource IRI plus pointer fragment:
2228
2211
` https://example.com/root.json#/$defs/A `
2229
2212
2230
- ` #/$defs/B ` : canonical (and base) ` IRI: https://example.com/other.json `
2213
+ Document location ` /$defs/B ` :
2214
+ - canonical (and base) ` IRI: https://example.com/other.json `
2231
2215
- canonical resource IRI plus pointer fragment:
2232
2216
` https://example.com/other.json# `
2233
- - base IRI of enclosing (root.json) resource plus fragment:
2234
- ` https://example.com/root.json#/$defs/B `
2235
2217
2236
- ` #/$defs/B/$defs/X ` : base IRI: ` https://example.com/other.json `
2218
+ Document location ` /$defs/B/$defs/X ` :
2219
+ - base IRI: ` https://example.com/other.json `
2237
2220
- canonical resource IRI plus plain fragment:
2238
2221
` https://example.com/other.json#bar `
2239
2222
- canonical resource IRI plus pointer fragment:
2240
2223
` https://example.com/other.json#/$defs/X `
2241
- - base IRI of enclosing (root.json) resource plus fragment:
2242
- ` https://example.com/root.json#/$defs/B/$defs/X `
2243
2224
2244
- ` #/$defs/B/$defs/Y ` : canonical (and base) IRI:
2225
+ Document location ` /$defs/B/$defs/Y ` :
2226
+ - canonical (and base) IRI:
2245
2227
` https://example.com/t/inner.json `
2246
2228
- canonical IRI plus plain fragment: ` https://example.com/t/inner.json#bar `
2247
2229
- canonical IRI plus pointer fragment: ` https://example.com/t/inner.json# `
2248
- - base IRI of enclosing (other.json) resource plus fragment:
2249
- ` https://example.com/other.json#/$defs/Y `
2250
- - base IRI of enclosing (root.json) resource plus fragment:
2251
- ` https://example.com/root.json#/$defs/B/$defs/Y `
2252
2230
2253
- ` #/$defs/C ` : canonical (and base) IRI:
2231
+ Document location ` /$defs/C ` :
2232
+ - canonical (and base) IRI:
2254
2233
` urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f `
2255
2234
- canonical IRI plus pointer fragment:
2256
2235
` urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# `
2257
- - base IRI of enclosing (root.json) resource plus fragment:
2258
- ` https://example.com/root.json#/$defs/C `
2259
2236
2260
2237
Note: The fragment part of the IRI does not make it canonical or non-canonical,
2261
2238
rather, the base IRI used (as part of the full IRI with any fragment) is what
2262
2239
determines the canonical nature of the resulting full IRI.[ ^ 18 ]
2263
2240
2264
2241
[ ^ 18 ] : Multiple "canonical" IRIs? We Acknowledge this is potentially confusing,
2265
- and direct you to read the CREF located in the [ JSON Pointer fragments and
2266
- embedded schema resources] ( #embedded ) section for further comments.
2242
+ and direct you to read the CREF located in {{embedded}} for further comments.
2243
+
2244
+ While the following IRIs do correctly indicate specific schemas, per the reasons
2245
+ outlined in {{embedded}}, they are to be avoided as they may not work in all implementations:
2246
+
2247
+ Document location ` /$defs/B ` :
2248
+ - canonical (and base) ` IRI: https://example.com/other.json `
2249
+ - base IRI of enclosing (root.json) resource plus fragment:
2250
+ ` https://example.com/root.json#/$defs/B `
2251
+
2252
+ Document location ` /$defs/B/$defs/X ` :
2253
+ - base IRI: ` https://example.com/other.json `
2254
+ - base IRI of enclosing (root.json) resource plus fragment:
2255
+ ` https://example.com/root.json#/$defs/B/$defs/X `
2256
+
2257
+ Document location ` /$defs/B/$defs/Y ` :
2258
+ - canonical (and base) IRI:
2259
+ ` https://example.com/t/inner.json `
2260
+ - base IRI of enclosing (other.json) resource plus fragment:
2261
+ ` https://example.com/other.json#/$defs/Y `
2262
+ - base IRI of enclosing (root.json) resource plus fragment:
2263
+ ` https://example.com/root.json#/$defs/B/$defs/Y `
2264
+
2265
+ Document location ` /$defs/C ` :
2266
+ - canonical (and base) IRI:
2267
+ ` urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f `
2268
+ - base IRI of enclosing (root.json) resource plus fragment:
2269
+ ` https://example.com/root.json#/$defs/C `
2267
2270
2268
2271
## [ Appendix] Manipulating schema documents and references
2269
2272
@@ -2284,9 +2287,9 @@ simplify coding so that various invocations of JSON Schema libraries do not have
2284
2287
to keep track of and load a large number of resources.
2285
2288
2286
2289
This transformation can be safely and reversibly done as long as all static
2287
- references (e.g. ` $ref ` ) use IRI- references that resolve to IRIs using the
2290
+ references (e.g. ` $ref ` ) use IRI references that resolve to IRIs using the
2288
2291
canonical resource IRI as the base, and all schema resources have an
2289
- absolute- IRI as the ` $id ` in their root schema.
2292
+ absolute IRI as the ` $id ` in their root schema.
2290
2293
2291
2294
With these conditions met, each external resource can be copied under ` $defs ` ,
2292
2295
without breaking any references among the resources' schema objects, and without
@@ -2470,7 +2473,7 @@ to the document.
2470
2473
- Clarify that detecting duplicate IRIs for different schemas SHOULD raise an
2471
2474
error
2472
2475
- Consolidate and clarify the syntax and rationale for plain-name fragments
2473
- - "$id" MUST be an absolute- IRI, without any fragment, even an empty one
2476
+ - "$id" MUST be an absolute IRI, without any fragment, even an empty one
2474
2477
- Note that an empty string "$id" results in duplicate IRIs for different
2475
2478
schemas
2476
2479
- Define empty schemas as empty (no longer allowing unrecognized keywords)
0 commit comments