Skip to content

Commit 1ccab5e

Browse files
committed
Expand $id example to show all valid URIs
This clarifies that JSON Pointers work from any base URI within a document to any location underneath that base, and shows that this can produce several different valid URIs for a subschema.
1 parent 194b545 commit 1ccab5e

File tree

1 file changed

+58
-19
lines changed

1 file changed

+58
-19
lines changed

jsonschema-core.xml

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,13 @@
584584
matches the above requirements nor is a valid JSON pointer
585585
is not defined.
586586
</t>
587-
<t>
588-
For example:
587+
<section title="Schema identification examples" anchor="idExamples">
589588
<figure>
589+
<preamble>
590+
Consider the following schema, which shows "$id" being used to identify
591+
the root schema, change the base URI for subschemas, and assign plain
592+
name fragments to subschemas:
593+
</preamble>
590594
<artwork>
591595
<![CDATA[
592596
{
@@ -608,23 +612,58 @@
608612
]]>
609613
</artwork>
610614
</figure>
611-
</t>
612-
<t>
613-
The schemas at the following URI-encoded <xref target="RFC6901">JSON
614-
Pointers</xref> (relative to the root schema) have the following
615-
base URIs, and are identifiable by either URI in accordance with
616-
Section <xref target="fragments" format="counter"></xref> above:
617-
</t>
618-
<t>
619-
<list style="hanging">
620-
<t hangText="# (document root)">http://example.com/root.json#</t>
621-
<t hangText="#/definitions/A">http://example.com/root.json#foo</t>
622-
<t hangText="#/definitions/B">http://example.com/other.json</t>
623-
<t hangText="#/definitions/B/definitions/X">http://example.com/other.json#bar</t>
624-
<t hangText="#/definitions/B/definitions/Y">http://example.com/t/inner.json</t>
625-
<t hangText="#/definitions/C">urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f</t>
626-
</list>
627-
</t>
615+
<t>
616+
The schemas at the following URI-encoded <xref target="RFC6901">JSON
617+
Pointers</xref> (relative to the root schema) have the following
618+
base URIs, and are identifiable by any listed URI in accordance with
619+
Section <xref target="fragments" format="counter"></xref> above:
620+
</t>
621+
<t>
622+
<list style="hanging">
623+
<t hangText="# (document root)">
624+
<list>
625+
<t>http://example.com/root.json</t>
626+
<t>http://example.com/root.json#</t>
627+
</list>
628+
</t>
629+
<t hangText="#/definitions/A">
630+
<list>
631+
<t>http://example.com/root.json#foo</t>
632+
<t>http://example.com/root.json#/definitions/A</t>
633+
</list>
634+
</t>
635+
<t hangText="#/definitions/B">
636+
<list>
637+
<t>http://example.com/other.json</t>
638+
<t>http://example.com/other.json#</t>
639+
<t>http://example.com/root.json#/definitions/B</t>
640+
</list>
641+
</t>
642+
<t hangText="#/definitions/B/definitions/X">
643+
<list>
644+
<t>http://example.com/other.json#bar</t>
645+
<t>http://example.com/other.json#/definitions/X</t>
646+
<t>http://example.com/root.json#/definitions/B/definitions/X</t>
647+
</list>
648+
</t>
649+
<t hangText="#/definitions/B/definitions/Y">
650+
<list>
651+
<t>http://example.com/t/inner.json</t>
652+
<t>http://example.com/t/inner.json#</t>
653+
<t>http://example.com/other.json#/definitions/Y</t>
654+
<t>http://example.com/root.json#/definitions/B/definitions/Y</t>
655+
</list>
656+
</t>
657+
<t hangText="#/definitions/C">
658+
<list>
659+
<t>urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f</t>
660+
<t>urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#</t>
661+
<t>http://example.com/root.json#/definitions/C</t>
662+
</list>
663+
</t>
664+
</list>
665+
</t>
666+
</section>
628667
</section>
629668

630669
<section title='Schema References With "$ref"'>

0 commit comments

Comments
 (0)