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