|
325 | 325 | </t>
|
326 | 326 | </section>
|
327 | 327 |
|
328 |
| - <section title='The "id" keyword'> |
| 328 | + <section title='The "$id" keyword'> |
329 | 329 | <t>
|
330 |
| - The "id" keyword defines a URI for the schema, |
| 330 | + The "$id" keyword defines a URI for the schema, |
331 | 331 | and the base URI that other URI references within the schema are resolved against.
|
332 |
| - The "id" keyword itself is resolved against the base URI that the object as a whole appears in. |
| 332 | + The "$id" keyword itself is resolved against the base URI that the object as a whole appears in. |
333 | 333 | </t>
|
334 | 334 | <t>
|
335 | 335 | If present, the value for this keyword MUST be a string, and MUST represent a valid <xref target="RFC3986">URI-reference</xref>.
|
336 | 336 | This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.
|
337 | 337 | </t>
|
338 | 338 | <t>
|
339 |
| - The root schema of a JSON Schema document SHOULD contain an "id" keyword with an absolute-URI (containing a scheme, but no fragment). |
| 339 | + The root schema of a JSON Schema document SHOULD contain an "$id" keyword with an absolute-URI (containing a scheme, but no fragment). |
340 | 340 | </t>
|
341 | 341 | <t>
|
342 | 342 | To name subschemas in a JSON Schema document,
|
343 |
| - subschemas can use "id" to give themselves a document-local identifier. |
344 |
| - This form of "id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference, |
| 343 | + subschemas can use "$id" to give themselves a document-local identifier. |
| 344 | + This form of "$id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference, |
345 | 345 | followed by a letter ([A-Za-z]), followed by any number of
|
346 | 346 | letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").
|
347 | 347 | <!-- This restriction is the same one defined by XML -->
|
|
352 | 352 | <artwork>
|
353 | 353 | <![CDATA[
|
354 | 354 | {
|
355 |
| - "id": "http://example.com/root.json", |
| 355 | + "$id": "http://example.com/root.json", |
356 | 356 | "definitions": {
|
357 |
| - "A": { "id": "#foo" }, |
| 357 | + "A": { "$id": "#foo" }, |
358 | 358 | "B": {
|
359 |
| - "id": "other.json", |
| 359 | + "$id": "other.json", |
360 | 360 | "definitions": {
|
361 |
| - "X": { "id": "#bar" }, |
362 |
| - "Y": { "id": "t/inner.json" } |
| 361 | + "X": { "$id": "#bar" }, |
| 362 | + "Y": { "$id": "t/inner.json" } |
363 | 363 | }
|
364 | 364 | },
|
365 | 365 | "C": {
|
366 |
| - "id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" |
| 366 | + "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" |
367 | 367 | }
|
368 | 368 | }
|
369 | 369 | }
|
|
389 | 389 | <section title="Internal references">
|
390 | 390 | <t>
|
391 | 391 | Schemas can be identified by any URI that has been given to them, including a JSON Pointer or
|
392 |
| - their URI given directly by "id". |
| 392 | + their URI given directly by "$id". |
393 | 393 | </t>
|
394 | 394 | <t>
|
395 |
| - Tools SHOULD take note of the URIs that schemas, including subschemas, provide for themselves using "id". |
| 395 | + Tools SHOULD take note of the URIs that schemas, including subschemas, provide for themselves using "$id". |
396 | 396 | This is known as "Internal referencing".
|
397 | 397 | </t>
|
398 | 398 |
|
|
404 | 404 | <artwork>
|
405 | 405 | <![CDATA[
|
406 | 406 | {
|
407 |
| - "id": "http://example.net/root.json", |
| 407 | + "$id": "http://example.net/root.json", |
408 | 408 | "items": {
|
409 | 409 | "type": "array",
|
410 | 410 | "items": { "$ref": "#item" }
|
411 | 411 | },
|
412 | 412 | "definitions": {
|
413 | 413 | "single": {
|
414 |
| - "id": "#item", |
| 414 | + "$id": "#item", |
415 | 415 | "type": "integer"
|
416 | 416 | },
|
417 | 417 | }
|
|
420 | 420 | </artwork>
|
421 | 421 | </figure>
|
422 | 422 | <t>
|
423 |
| - When an implementation encounters the <#/definitions/single> schema, it resolves the "id" URI reference |
| 423 | + When an implementation encounters the <#/definitions/single> schema, it resolves the "$id" URI reference |
424 | 424 | against the current base URI to form <http://example.net/root.json#item>.
|
425 | 425 | </t>
|
426 | 426 | <t>
|
|
436 | 436 | </t>
|
437 | 437 | <t>
|
438 | 438 | Implementations SHOULD be able to associate arbritrary URIs with an arbritrary schema and/or
|
439 |
| - automatically associate a schema's "id"-given URI, depending on the trust that the the validator |
| 439 | + automatically associate a schema's "$id"-given URI, depending on the trust that the the validator |
440 | 440 | has in the schema.
|
441 | 441 | </t>
|
442 | 442 | <t>
|
443 | 443 | A schema MAY (and likely will) have multiple URIs, but there is no way for a URI to identify more than one schema.
|
444 | 444 | When multiple schemas try to identify with the same URI, validators SHOULD raise an error condition.
|
445 | 445 | </t>
|
446 | 446 | </section>
|
| 447 | + <section title='"id" as a deprecated form of "$id"'> |
| 448 | + <t> |
| 449 | + Previous drafts of this specification used "id" in place of "$id". Implementations |
| 450 | + SHOULD continue to support "id" unless and until it is removed in a future draft. |
| 451 | + To facilitate interoperability during the transitions, implementations supporting |
| 452 | + both keywords MUST NOT produce an error if both are present with the same value. |
| 453 | + </t> |
| 454 | + <t> |
| 455 | + The behavior when "$id" and "id" are present with different values is undefined. |
| 456 | + Implementations MAY issue a warning or error for such schemas. |
| 457 | + </t> |
| 458 | + </section> |
447 | 459 | </section>
|
448 | 460 | </section>
|
449 | 461 |
|
@@ -565,7 +577,7 @@ User-Agent: so-cool-json-schema/1.0.2 curl/7.43.0
|
565 | 577 | Validators MUST NOT fall into an infinite loop.
|
566 | 578 | </t>
|
567 | 579 | <t>
|
568 |
| - 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". |
| 580 | + 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". |
569 | 581 | </t>
|
570 | 582 | <t>
|
571 | 583 | Individual JSON Schema vocabularies are liable to also have their own security considerations. Consult the respective specifications for more information.
|
|
0 commit comments