|
1515 | 1515 | If present, the value for this keyword MUST be a string, and MUST represent a
|
1516 | 1516 | valid <xref target="RFC3986">URI-reference</xref>. This URI-reference
|
1517 | 1517 | SHOULD be normalized, and MUST resolve to an
|
1518 |
| - <xref target="RFC3986">absolute-URI</xref> (without a fragment). |
| 1518 | + <xref target="RFC3986">absolute-URI</xref> (without a fragment). Therefore, |
| 1519 | + "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT contain an |
| 1520 | + empty fragment. |
| 1521 | + </t> |
| 1522 | + <t> |
| 1523 | + Since an empty fragment in the context of the application/schema+json media |
| 1524 | + type refers to the same resource as the base URI without a fragment, |
| 1525 | + an implementation MAY normalize a URI ending with an empty fragment by removing |
| 1526 | + the fragment. However, schema authors SHOULD NOT rely on this behavior |
| 1527 | + across implementations. |
| 1528 | + <cref> |
| 1529 | + This is primarily allowed because older meta-schemas have an empty |
| 1530 | + fragment in their $id (or previously, id). A future draft may outright |
| 1531 | + forbid even empty fragments in "$id". |
| 1532 | + </cref> |
1519 | 1533 | </t>
|
1520 | 1534 | <t>
|
1521 | 1535 | This URI also serves as the base URI for relative URI-references in keywords
|
|
1543 | 1557 | but no fragment).
|
1544 | 1558 | </t>
|
1545 | 1559 | </section>
|
1546 |
| - <section title="JSON Pointer fragments and embedded schema resources"> |
| 1560 | + <section title="JSON Pointer fragments and embedded schema resources" |
| 1561 | + anchor="embedded"> |
1547 | 1562 | <t>
|
1548 | 1563 | Since JSON Pointer URI fragments are constructed based on the structure
|
1549 | 1564 | of the schema document, an embedded schema resource and its subschemas
|
|
1576 | 1591 | schema resource's URI cease to be valid when the embedded schema
|
1577 | 1592 | is moved to a separate document and referenced, applications and schemas
|
1578 | 1593 | SHOULD NOT use such URIs to identify embedded schema resources or
|
1579 |
| - locations within them. The effect of using such URIs is undefined. |
1580 |
| - Implementations MAY produce an error requiring that the canonical |
1581 |
| - URI for the embedded resource be used. |
| 1594 | + locations within them. |
| 1595 | + </t> |
| 1596 | + <t> |
| 1597 | + Using such URIs is unreliable, and an implementation MAY choose not to |
| 1598 | + support them. If an embedded schema were to be replaced with a reference, |
| 1599 | + then the JSON Pointer fragment URI for that schema relative to its |
| 1600 | + parent's base URI would then identify the reference, while JSON Pointers |
| 1601 | + to locations within the formerly embedded resource would become invalid. |
| 1602 | + <cref> |
| 1603 | + If the change regarding reference replacement noted in the previous |
| 1604 | + CREF were to be implemented, the pointer behavior would be more |
| 1605 | + consistent. Really it is the pointers to deeper locations within |
| 1606 | + embedded schemas which should be strongly discouraged and |
| 1607 | + need not be supported. |
| 1608 | + </cref> |
1582 | 1609 | </t>
|
1583 | 1610 | <t>
|
1584 |
| - Examples of such URIs with undefined behavior, as well as the appropriate |
| 1611 | + Examples of such non-canonical URIs, as well as the appropriate |
1585 | 1612 | canonical URIs to use instead, are provided in section
|
1586 | 1613 | <xref target="idExamples" format="counter"></xref>.
|
1587 | 1614 | </t>
|
|
1654 | 1681 | The schemas at the following URI-encoded <xref target="RFC6901">JSON
|
1655 | 1682 | Pointers</xref> (relative to the root schema) have the following
|
1656 | 1683 | base URIs, and are identifiable by any listed URI in accordance with
|
1657 |
| - Section <xref target="fragments" format="counter"></xref> above: |
| 1684 | + sections <xref target="fragments" format="counter"></xref> and |
| 1685 | + <xref target="embedded" format="counter"></xref> above. As previously |
| 1686 | + noted, support for non-canonical URIs is OPTIONAL. |
1658 | 1687 | </t>
|
1659 | 1688 | <t>
|
1660 | 1689 | <list style="hanging">
|
|
1685 | 1714 | <t hangText="canonical URI with pointer fragment">
|
1686 | 1715 | https://example.com/other.json#
|
1687 | 1716 | </t>
|
1688 |
| - <t hangText="Fragment relative to root.json (undefined behavior)"> |
| 1717 | + <t hangText="non-canonical URI with fragment relative to root.json"> |
1689 | 1718 | https://example.com/root.json#/$defs/B
|
1690 | 1719 | </t>
|
1691 | 1720 | </list>
|
|
1699 | 1728 | <t hangText="canonical URI with pointer fragment">
|
1700 | 1729 | https://example.com/other.json#/$defs/X
|
1701 | 1730 | </t>
|
1702 |
| - <t hangText="Fragment relative to root.json (undefined behavior)"> |
| 1731 | + <t hangText="non-canonical URI with fragment relative to root.json"> |
1703 | 1732 | https://example.com/root.json#/$defs/B/$defs/X
|
1704 | 1733 | </t>
|
1705 | 1734 | </list>
|
|
1713 | 1742 | <t hangText="canonical URI with pointer fragment">
|
1714 | 1743 | https://example.com/t/inner.json#
|
1715 | 1744 | </t>
|
1716 |
| - <t hangText="Fragment relative to other.json (undefined behavior)"> |
| 1745 | + <t hangText="non-canonical URI with fragment relative to other.json"> |
1717 | 1746 | https://example.com/other.json#/$defs/Y
|
1718 | 1747 | </t>
|
1719 |
| - <t hangText="Fragment relative to root.json (undefined behavior)"> |
| 1748 | + <t hangText="non-canonical URI with fragment relative to root.json"> |
1720 | 1749 | https://example.com/root.json#/$defs/B/$defs/Y
|
1721 | 1750 | </t>
|
1722 | 1751 | </list>
|
|
1729 | 1758 | <t hangText="canonical URI with pointer fragment">
|
1730 | 1759 | urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
|
1731 | 1760 | </t>
|
1732 |
| - <t hangText="Fragment relative to root.json (undefined behavior)"> |
| 1761 | + <t hangText="non-canonical URI with fragment relative to root.json"> |
1733 | 1762 | https://example.com/root.json#/$defs/C
|
1734 | 1763 | </t>
|
1735 | 1764 | </list>
|
|
0 commit comments