Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 66d05d2

Browse files
committed
id -> $id
1 parent a080034 commit 66d05d2

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

source/basics.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,15 @@ more information.
9999
Declaring a unique identifier
100100
-----------------------------
101101

102-
It is also best practice to include an ``id`` property as a unique
102+
It is also best practice to include an ``$id`` property as a unique
103103
identifier for each schema. For now, just set it to a URL at a domain
104104
you control, for example::
105105

106-
{ "id": "http://yourdomain.com/schemas/myschema.json" }
106+
{ "$id": "http://yourdomain.com/schemas/myschema.json" }
107107

108108
The details of `id` become more apparent when you start `structuring`.
109+
110+
.. draft_specific::
111+
112+
--Draft 4
113+
In Draft 4, ``$id`` is just ``id`` (without the dollar-sign).

source/structuring.rst

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,33 +141,44 @@ schema for a customer:
141141

142142
.. _id:
143143

144-
The id property
145-
---------------
144+
The $id property
145+
----------------
146146

147-
The ``id`` property serves two purposes:
147+
|draft6|
148+
149+
The ``$id`` property serves two purposes:
148150

149151
- It declares a unique identifier for the schema.
150152

151153
- It declares a base URL against which ``$ref`` URLs are resolved.
152154

153-
It is best practice that ``id`` is a URL, preferably in a domain that
155+
It is best practice that ``$id`` is a URL, preferably in a domain that
154156
you control. For example, if you own the ``foo.bar`` domain, and you
155-
had a schema for addresses, you may set its ``id`` as follows::
157+
had a schema for addresses, you may set its ``$id`` as follows:
158+
159+
.. schema_example::
156160

157-
"id": "http://foo.bar/schemas/address.json"
161+
{ "$id": "http://foo.bar/schemas/address.json" }
158162

159163
This provides a unique identifier for the schema, as well as, in most
160164
cases, indicating where it may be downloaded.
161165

162-
But be aware of the second purpose of the ``id`` property: that it
166+
But be aware of the second purpose of the ``$id`` property: that it
163167
declares a base URL for relative ``$ref`` URLs elsewhere in the file.
164-
For example, if you had::
168+
For example, if you had:
169+
170+
.. schema_example::
165171

166172
{ "$ref": "person.json" }
167173

168-
in the same file, a JSON schema validation library would fetch
169-
``person.json`` from ``http://foo.bar/schemas/person.json``, even if
170-
``address.json`` was loaded from the local filesystem.
174+
in the same file, a JSON schema validation library would fetch ``person.json``
175+
from ``http://foo.bar/schemas/person.json``, even if ``address.json`` was loaded
176+
from somewhere else, such as the local filesystem.
177+
178+
.. draft_specific::
179+
180+
--Draft 4
181+
In Draft 4, ``$id`` is just ``id`` (without the dollar sign).
171182

172183
Extending
173184
---------

0 commit comments

Comments
 (0)