|
176 | 176 | <section title="JSON Schema primitive types">
|
177 | 177 | <t>
|
178 | 178 | JSON Schema defines seven primitive types for JSON values:
|
| 179 | + <!-- TODO integer and number are both the same syntax, integer is just a subset --> |
179 | 180 | <list style="hanging">
|
180 | 181 | <t hangText="array">A JSON array.</t>
|
181 | 182 | <t hangText="boolean">A JSON boolean.</t>
|
|
221 | 222 | </t>
|
222 | 223 |
|
223 | 224 | <t>
|
224 |
| - An instance may also be referred to as "JSON instance", or "JSON data". |
| 225 | + An instance may also be referred to as a "JSON instance", "JSON data", or "JSON document". |
225 | 226 | </t>
|
226 | 227 | </section>
|
227 | 228 |
|
|
333 | 334 |
|
334 | 335 | <section title='The "$schema" keyword'>
|
335 | 336 | <section title="Purpose">
|
| 337 | + <!-- TODO a custom $schema keyword might also be used to enforce minimum required functionality of a validator --> |
336 | 338 | <t>
|
337 | 339 | The "$schema" keyword is both used as a JSON Schema version identifier and the
|
338 | 340 | location of a resource which is itself a JSON Schema, which describes any schema
|
|
342 | 344 | <t>
|
343 | 345 | This keyword SHOULD be located at the root of a JSON Schema. The value of this
|
344 | 346 | keyword MUST be a <xref target="RFC3986">URI</xref> and a valid <xref
|
345 |
| - target="json-reference">JSON Reference</xref>; this URI MUST be both absolute |
346 |
| - and normalized. The resource located at this URI MUST successfully describe |
347 |
| - itself. It is RECOMMENDED that schema authors include this keyword in their |
| 347 | + target="json-reference">JSON Reference</xref>; this URI MUST be normalized. |
| 348 | + The resource identified by this URI MUST successfully describe the current |
| 349 | + schema document. It is RECOMMENDED that schema authors include this keyword in their |
348 | 350 | schemas.
|
349 | 351 | </t>
|
350 | 352 |
|
|
375 | 377 |
|
376 | 378 | </section>
|
377 | 379 |
|
378 |
| - <section title="URI resolution scopes and dereferencing"> |
| 380 | + <section title="Base URI and dereferencing"> |
379 | 381 | <section title="Definition">
|
380 | 382 | <t>
|
381 | 383 | JSON Schema uses <xref target="json-reference">JSON Reference</xref> as a
|
382 | 384 | mechanism for schema addressing. It extends this specification in two ways:
|
383 | 385 |
|
384 | 386 | <list>
|
385 | 387 | <t>JSON Schema offers facilities to alter the base URI against which a
|
386 |
| - reference must resolve by the means of the "id" keyword;</t> |
| 388 | + URI reference must resolve by the means of the "id" keyword;</t> |
387 | 389 | <t>it offers schemas a mechanism to declare their own URIs, placing no limits on the structure of the URI</t>
|
388 | 390 | </list>
|
389 | 391 |
|
390 | 392 | </t>
|
391 | 393 |
|
392 | 394 | <t>
|
393 |
| - Altering the URI within a schema is called defining a new resolution scope. |
394 |
| - The initial resolution scope of a schema is the URI of the schema itself, or a suitable substitute URI if none is known. |
| 395 | + <!-- TODO: RFC3986 defines exactly how to do this --> |
| 396 | + The initial base URI of a schema is the URI of the schema itself, or a suitable substitute URI if none is known. |
395 | 397 | </t>
|
396 | 398 | </section>
|
397 | 399 |
|
398 |
| - <section title='URI resolution scope alteration with the "id" keyword'> |
399 |
| - |
| 400 | + <section title='Base URI alteration with the "id" keyword'> |
400 | 401 | <section title="Valid values">
|
401 | 402 | <t>
|
402 |
| - The value for this keyword MUST be a string, and MUST be a valid URI (relative or absolute). |
| 403 | + The value for this keyword MUST be a string, and MUST be a valid URI-reference [RFC3986]. |
403 | 404 | This URI SHOULD be normalized, and SHOULD NOT be an empty fragment (#) or the empty string.
|
404 | 405 | </t>
|
405 | 406 | </section>
|
406 | 407 |
|
407 | 408 | <section title="Usage">
|
408 | 409 | <t>
|
409 |
| - The "id" keyword is used to alter the resolution scope. |
410 |
| - When an id is encountered, an implementation MUST resolve this id against |
411 |
| - the most immediate parent scope. The resolved URI will be the new resolution |
412 |
| - scope for this subschema and all its children, until another "id" is |
413 |
| - encountered. |
| 410 | + The "id" keyword defines the URI of the schema and the base URI that other URI references within |
| 411 | + the schema are resolved against. The "id" keyword itself is resolved against a base URI as |
| 412 | + specified in [RFC3986]. |
414 | 413 | </t>
|
415 |
| - |
416 | 414 | <t>
|
417 |
| - When using "id" to alter resolution scopes, schema authors SHOULD ensure |
418 |
| - that resolution scopes are unique within the schema. |
| 415 | + The outermost schema of a JSON Schema document SHOULD be an absolute-URI (containing a scheme, but no fragment) |
| 416 | + or an absolute-URI with an empty fragment. |
419 | 417 | </t>
|
420 |
| - |
421 | 418 | <t>
|
422 |
| - This schema will be taken as an example: |
| 419 | + For example: |
423 | 420 | </t>
|
424 |
| - |
425 |
| - <!-- |
426 |
| - FIXME: http again as a scheme, maybe another one? It can be any scheme after |
427 |
| - all |
428 |
| - --> |
429 | 421 | <figure>
|
430 | 422 | <artwork>
|
431 | 423 | <![CDATA[
|
432 | 424 | {
|
433 |
| - "id": "http://x.y.z/rootschema.json#", |
| 425 | + "id": "http://example.com/rootschema.json#", |
434 | 426 | "schema1": {
|
435 | 427 | "id": "#foo"
|
436 | 428 | },
|
|
444 | 436 | }
|
445 | 437 | },
|
446 | 438 | "schema3": {
|
447 |
| - "id": "some://where.else/completely#" |
| 439 | + "id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" |
448 | 440 | }
|
449 | 441 | }
|
450 | 442 | ]]>
|
|
454 | 446 | <t>
|
455 | 447 | Subschemas at the following URI-encoded <xref target="json-pointer">JSON
|
456 | 448 | Pointer</xref>s (starting from the root schema) define the following
|
457 |
| - resolution scopes: |
458 |
| - |
| 449 | + base URIs: |
| 450 | + |
459 | 451 | <list style="hanging">
|
460 |
| - <t hangText="# (document root)">http://x.y.z/rootschema.json#</t> |
461 |
| - <t hangText="#/schema1">http://x.y.z/rootschema.json#foo</t> |
462 |
| - <t hangText="#/schema2">http://x.y.z/otherschema.json#</t> |
463 |
| - <t hangText="#/schema2/nested">http://x.y.z/otherschema.json#bar</t> |
464 |
| - <t hangText="#/schema2/alsonested">http://x.y.z/t/inner.json#a</t> |
465 |
| - <t hangText="#/schema3">some://where.else/completely#</t> |
| 452 | + <t hangText="# (document root)">http://example.com/rootschema.json#</t> |
| 453 | + <t hangText="#/schema1">http://example.com/rootschema.json#foo</t> |
| 454 | + <t hangText="#/schema2">http://example.com/otherschema.json#</t> |
| 455 | + <t hangText="#/schema2/nested">http://example.com/otherschema.json#bar</t> |
| 456 | + <t hangText="#/schema2/alsonested">http://example.com/t/inner.json#a</t> |
| 457 | + <t hangText="#/schema3">urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f</t> |
466 | 458 | </list>
|
467 | 459 | </t>
|
468 | 460 |
|
|
504 | 496 |
|
505 | 497 | <t>
|
506 | 498 | When an implementation encounters the "schema1" reference, it resolves it
|
507 |
| - against the most immediate parent scope, leading to URI |
| 499 | + against the current base URI, leading to URI |
508 | 500 | "http://my.site/schema1#". The way to process this URI will differ
|
509 | 501 | according to the chosen dereferencing mode:
|
510 | 502 |
|
511 | 503 | <list>
|
512 | 504 | <t>if canonical dereferencing is used, the implementation will
|
513 | 505 | dereference this URI, and fetch the content at this URI;</t>
|
514 | 506 | <t>if inline dereferencing is used, the implementation MAY notice that
|
515 |
| - URI scope "http://my.site/schema1#" is already defined within the |
| 507 | + the base URI "http://my.site/schema1#" is already defined within the |
516 | 508 | schema, and choose to use the appropriate subschema.</t>
|
517 | 509 | </list>
|
518 | 510 | </t>
|
|
521 | 513 |
|
522 | 514 | <section title="Inline dereferencing and fragments">
|
523 | 515 | <t>
|
524 |
| - When using inline dereferencing, a resolution scope may lead to a URI which |
| 516 | + When using inline dereferencing, a base URI may lead to a URI which |
525 | 517 | has a non-empty fragment part which is not a JSON Pointer, as in this
|
526 | 518 | example:
|
527 | 519 | </t>
|
|
576 | 568 | </t>
|
577 | 569 |
|
578 | 570 | <section title='Correlation by means of the "Link" header'>
|
| 571 | + <!-- HTTP linking is referenced by specs that have nothing to do with HTTP, so this isn't always the case --> |
579 | 572 | <t>
|
580 | 573 | It is RECOMMENDED that instances be associated with JSON Schemas using the link relation "describedby", as defined by <xref target="RFC5988">RFC 5988, section 5.3</xref>.
|
581 | 574 | </t>
|
|
0 commit comments