@@ -141,33 +141,44 @@ schema for a customer:
141
141
142
142
.. _id :
143
143
144
- The id property
145
- ---------------
144
+ The $ id property
145
+ ----------------
146
146
147
- The ``id `` property serves two purposes:
147
+ |draft6 |
148
+
149
+ The ``$id `` property serves two purposes:
148
150
149
151
- It declares a unique identifier for the schema.
150
152
151
153
- It declares a base URL against which ``$ref `` URLs are resolved.
152
154
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
154
156
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 ::
156
160
157
- " id": "http://foo.bar/schemas/address.json"
161
+ { "$ id": "http://foo.bar/schemas/address.json" }
158
162
159
163
This provides a unique identifier for the schema, as well as, in most
160
164
cases, indicating where it may be downloaded.
161
165
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
163
167
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 ::
165
171
166
172
{ "$ref": "person.json" }
167
173
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).
171
182
172
183
Extending
173
184
---------
0 commit comments