|
340 | 340 | </t>
|
341 | 341 | </section>
|
342 | 342 |
|
343 |
| - <section title='The "id" keyword'> |
| 343 | + <section title='The "$id" keyword'> |
344 | 344 | <t>
|
345 |
| - The "id" keyword defines a URI for the schema, |
| 345 | + The "$id" keyword defines a URI for the schema, |
346 | 346 | and the base URI that other URI references within the schema are resolved against.
|
347 |
| - The "id" keyword itself is resolved against the base URI that the object as a whole appears in. |
| 347 | + The "$id" keyword itself is resolved against the base URI that the object as a whole appears in. |
348 | 348 | </t>
|
349 | 349 | <t>
|
350 | 350 | If present, the value for this keyword MUST be a string, and MUST represent a valid <xref target="RFC3986">URI-reference</xref>.
|
351 | 351 | This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.
|
352 | 352 | </t>
|
353 | 353 | <t>
|
354 |
| - The root schema of a JSON Schema document SHOULD contain an "id" keyword with an absolute-URI (containing a scheme, but no fragment). |
| 354 | + The root schema of a JSON Schema document SHOULD contain an "$id" keyword with an absolute-URI (containing a scheme, but no fragment). |
355 | 355 | </t>
|
356 | 356 | <t>
|
357 | 357 | To name subschemas in a JSON Schema document,
|
358 |
| - subschemas can use "id" to give themselves a document-local identifier. |
359 |
| - This form of "id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference, |
| 358 | + subschemas can use "$id" to give themselves a document-local identifier. |
| 359 | + This form of "$id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference, |
360 | 360 | followed by a letter ([A-Za-z]), followed by any number of
|
361 | 361 | letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").
|
362 | 362 | <!-- This restriction is the same one defined by XML -->
|
|
367 | 367 | <artwork>
|
368 | 368 | <![CDATA[
|
369 | 369 | {
|
370 |
| - "id": "http://example.com/root.json", |
| 370 | + "$id": "http://example.com/root.json", |
371 | 371 | "definitions": {
|
372 |
| - "A": { "id": "#foo" }, |
| 372 | + "A": { "$id": "#foo" }, |
373 | 373 | "B": {
|
374 |
| - "id": "other.json", |
| 374 | + "$id": "other.json", |
375 | 375 | "definitions": {
|
376 |
| - "X": { "id": "#bar" }, |
377 |
| - "Y": { "id": "t/inner.json" } |
| 376 | + "X": { "$id": "#bar" }, |
| 377 | + "Y": { "$id": "t/inner.json" } |
378 | 378 | }
|
379 | 379 | },
|
380 | 380 | "C": {
|
381 |
| - "id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" |
| 381 | + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" |
382 | 382 | }
|
383 | 383 | }
|
384 | 384 | }
|
|
404 | 404 | <section title="Internal references">
|
405 | 405 | <t>
|
406 | 406 | Schemas can be identified by any URI that has been given to them, including a JSON Pointer or
|
407 |
| - their URI given directly by "id". |
| 407 | + their URI given directly by "$id". |
408 | 408 | </t>
|
409 | 409 | <t>
|
410 |
| - Tools SHOULD take note of the URIs that schemas, including subschemas, provide for themselves using "id". |
| 410 | + Tools SHOULD take note of the URIs that schemas, including subschemas, provide for themselves using "$id". |
411 | 411 | This is known as "Internal referencing".
|
412 | 412 | </t>
|
413 | 413 |
|
|
419 | 419 | <artwork>
|
420 | 420 | <![CDATA[
|
421 | 421 | {
|
422 |
| - "id": "http://example.net/root.json", |
| 422 | + "$id": "http://example.net/root.json", |
423 | 423 | "items": {
|
424 | 424 | "type": "array",
|
425 | 425 | "items": { "$ref": "#item" }
|
426 | 426 | },
|
427 | 427 | "definitions": {
|
428 | 428 | "single": {
|
429 |
| - "id": "#item", |
| 429 | + "$id": "#item", |
430 | 430 | "type": "integer"
|
431 | 431 | },
|
432 | 432 | }
|
|
435 | 435 | </artwork>
|
436 | 436 | </figure>
|
437 | 437 | <t>
|
438 |
| - When an implementation encounters the <#/definitions/single> schema, it resolves the "id" URI reference |
| 438 | + When an implementation encounters the <#/definitions/single> schema, it resolves the "$id" URI reference |
439 | 439 | against the current base URI to form <http://example.net/root.json#item>.
|
440 | 440 | </t>
|
441 | 441 | <t>
|
|
451 | 451 | </t>
|
452 | 452 | <t>
|
453 | 453 | Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or
|
454 |
| - automatically associate a schema's "id"-given URI, depending on the trust that the the validator |
| 454 | + automatically associate a schema's "$id"-given URI, depending on the trust that the the validator |
455 | 455 | has in the schema.
|
456 | 456 | </t>
|
457 | 457 | <t>
|
458 | 458 | A schema MAY (and likely will) have multiple URIs, but there is no way for a URI to identify more than one schema.
|
459 | 459 | When multiple schemas try to identify with the same URI, validators SHOULD raise an error condition.
|
460 | 460 | </t>
|
461 | 461 | </section>
|
| 462 | + <section title='Compatibility with "id"'> |
| 463 | + <t><cref>"id" is likely to be deleted from the spec before RFC.</cref></t> |
| 464 | + <t> |
| 465 | + Implementations MAY support "id" as a synonym for "$id" to aid |
| 466 | + in migrating schemas from older drafts, however schema authors |
| 467 | + SHOULD NOT make use of "id" and MUST NOT assume it is supported. |
| 468 | + </t> |
| 469 | + <t> |
| 470 | + The behavior when "$id" and "id" are present with different values is undefined. |
| 471 | + Implementations MAY issue a warning or error for such schemas. |
| 472 | + </t> |
| 473 | + </section> |
462 | 474 | </section>
|
463 | 475 | </section>
|
464 | 476 |
|
@@ -580,7 +592,7 @@ User-Agent: so-cool-json-schema/1.0.2 curl/7.43.0
|
580 | 592 | Validators MUST NOT fall into an infinite loop.
|
581 | 593 | </t>
|
582 | 594 | <t>
|
583 |
| - Servers need to take care that malicious parties can't change the functionality of existing schemas by uploading a schema with an pre-existing or very similar "id". |
| 595 | + Servers need to take care that malicious parties can't change the functionality of existing schemas by uploading a schema with an pre-existing or very similar "$id". |
584 | 596 | </t>
|
585 | 597 | <t>
|
586 | 598 | Individual JSON Schema vocabularies are liable to also have their own security considerations. Consult the respective specifications for more information.
|
|
0 commit comments