|
336 | 336 | </t>
|
337 | 337 | <t>
|
338 | 338 | The value for this keyword MUST be a string, and MUST represent a valid <xref target="RFC3986">URI-reference</xref>.
|
339 |
| - This URI SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string ><. |
| 339 | + This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>. |
340 | 340 | </t>
|
341 | 341 | <t>
|
342 |
| - The root schema of a JSON Schema document SHOULD specify an absolute-URI "id" (containing a scheme, but no fragment). |
| 342 | + The root schema of a JSON Schema document SHOULD have an "id" with a valid absolute-URI (containing a scheme, but no fragment). |
343 | 343 | </t>
|
344 | 344 | <t>
|
345 |
| - To identify a particular subschema in a document without needing a JSON Pointer, |
346 |
| - subschemas can give themselves ids that can be identified by a fragment-part. |
347 |
| - These "id" keywords with a fragment MUST begin with a letter ([A-Za-z]), to be followed by any number of |
348 |
| - letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). |
349 |
| - <!-- This restriction is the one defined by XML --> |
| 345 | + To facilitate the identification of subschemas in a JSON Schema document, |
| 346 | + subschemas can use "id" to give themselves a URI with a custom fragment-part. |
| 347 | + This form of "id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference, |
| 348 | + followed by a letter ([A-Za-z]), followed by any number of |
| 349 | + letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods ("."). |
| 350 | + <!-- This restriction is the same one defined by XML --> |
350 | 351 | </t>
|
351 | 352 | <t>
|
352 | 353 | For example:
|
|
406 | 407 | <artwork>
|
407 | 408 | <![CDATA[
|
408 | 409 | {
|
409 |
| - "id": "http://example.net/myschema#", |
| 410 | + "id": "http://example.net/root.json#", |
410 | 411 | "definitions": {
|
411 |
| - "schema1": { |
| 412 | + "single": { |
412 | 413 | "id": "schema1",
|
413 | 414 | "type": "integer"
|
414 | 415 | },
|
415 |
| - "schema2", { |
416 |
| - "type": "array", |
417 |
| - "items": { "$ref": "schema1" } |
418 |
| - } |
| 416 | + }, |
| 417 | + "items": { |
| 418 | + "type": "array", |
| 419 | + "items": { "$ref": "schema1" } |
419 | 420 | }
|
420 | 421 | }
|
421 | 422 | ]]>
|
422 | 423 | </artwork>
|
423 | 424 | </figure>
|
424 | 425 | <t>
|
425 |
| - When an implementation encounters the <schema1> schema, it resolves the "id" URI reference |
426 |
| - against the current base URI, resolving to <http://example.net/schema1>. |
| 426 | + When an implementation encounters the <#/definitions/single> schema, it resolves the "id" URI reference |
| 427 | + against the current base URI to <http://example.net/schema1>. |
427 | 428 | </t>
|
428 | 429 | <t>
|
429 |
| - When an implementation then looks inside the <schema2> schema, it encounters the <schema1> reference, |
430 |
| - and resolves this the URI <http://example.net/schema1> which is understood as the schema defined elsewhere in the same document. |
| 430 | + When an implementation then looks inside the <#/items> schema, it encounters the <schema1> reference, |
| 431 | + and resolves this to <http://example.net/schema1> which is understood as the schema defined elsewhere in the same document. |
431 | 432 | </t>
|
432 |
| - <figure> |
433 |
| - <preamble> |
434 |
| - An example with fragment "id" keywords: |
435 |
| - </preamble> |
436 |
| - <artwork> |
437 |
| -<![CDATA[ |
438 |
| -{ |
439 |
| - "id": "http://some.site/schema#", |
440 |
| - "not": { "$ref": "#inner" }, |
441 |
| - "definitions": { |
442 |
| - "schema1": { |
443 |
| - "id": "#inner", |
444 |
| - "type": "boolean" |
445 |
| - } |
446 |
| - } |
447 |
| -} |
448 |
| -]]> |
449 |
| - </artwork> |
450 |
| - </figure> |
451 | 433 | </section>
|
452 | 434 | <section title="External references">
|
453 | 435 | <t>
|
454 | 436 | To differentiate schemas between each other in a vast ecosystem, schemas are identified by URI.
|
455 | 437 | As specified above, this does not necessarially mean anything is downloaded, but instead JSON Schema
|
456 |
| - implementations SHOULD provide ways to import a schema so that other schemas can reference it. |
| 438 | + implementations SHOULD provide ways to import a schema by URI so that other schemas can successfully reference it. |
457 | 439 | </t>
|
458 | 440 | <t>
|
459 | 441 | Implementations SHOULD be able to associate arbritrary URIs with an arbritrary schema and/or
|
460 | 442 | automatically associate a schema's "id"-given URI, depending on the trust that the the validator
|
461 | 443 | has in the schema.
|
462 | 444 | </t>
|
463 | 445 | <t>
|
464 |
| - A schema may have multiple URIs, but a URI must identify not more than one schema. |
| 446 | + A schema MAY (and likely will) have multiple URIs, but a URI has no way to identify more than one schema. |
465 | 447 | Validators that try to have multiple schemas associated to the same URI SHOULD raise an error condition.
|
466 | 448 | </t>
|
467 | 449 | </section>
|
|
0 commit comments