Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion content/draft6/core/id.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
keyword: "$id"
signature: "URI Reference"
value: This keyword must be set to an absolute URI or a relative reference as defined by [RFC 3986](https://www.rfc-editor.org/info/rfc3986)
value: "This keyword must be set to an absolute URI or a relative reference as defined by [RFC 3986](https://www.rfc-editor.org/info/rfc3986), where any fragment must match the regular expression `^[A-Za-z][-A-Za-z0-9.:_]*$`"
summary: "This keyword declares an identifier for the schema resource."
kind: [ "identifier" ]
instance: [ "any" ]
Expand Down Expand Up @@ -54,6 +54,23 @@ identifiers.

{{</common-pitfall>}}

{{<common-pitfall>}}

The specification restricts the kinds of fragments that may appear in
[`$id`]({{< ref "draft6/core/id" >}}). Only _plain-name_ fragments (matching
the regular expression `^[A-Za-z][-A-Za-z0-9.:_]*$`) are allowed, and they
declare a location-independent identifier (an anchor) for the schema. JSON
Pointer fragments such as `#/definitions/foo` are _not_ valid in
[`$id`]({{< ref "draft6/core/id" >}}), even though they are valid in
[`$ref`]({{< ref "draft6/core/ref" >}}). The behaviour of any other fragment
form is undefined.

This anchor-style usage of [`$id`]({{< ref "draft6/core/id" >}}) was later
replaced by the dedicated [`$anchor`]({{< ref "2019-09/core/anchor" >}})
keyword starting in JSON Schema 2019-09.

{{</common-pitfall>}}

{{<best-practice>}}

It is strongly recommended for every schema file to explicitly declare an
Expand Down
19 changes: 18 additions & 1 deletion content/draft7/core/id.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
keyword: "$id"
signature: "URI Reference"
value: This keyword must be set to an absolute URI or a relative reference as defined by [RFC 3986](https://www.rfc-editor.org/info/rfc3986)
value: "This keyword must be set to an absolute URI or a relative reference as defined by [RFC 3986](https://www.rfc-editor.org/info/rfc3986), where any fragment must match the regular expression `^[A-Za-z][-A-Za-z0-9.:_]*$`"
summary: "This keyword declares an identifier for the schema resource."
kind: [ "identifier" ]
instance: [ "any" ]
Expand Down Expand Up @@ -54,6 +54,23 @@ identifiers.

{{</common-pitfall>}}

{{<common-pitfall>}}

The specification restricts the kinds of fragments that may appear in
[`$id`]({{< ref "draft7/core/id" >}}). Only _plain-name_ fragments (matching
the regular expression `^[A-Za-z][-A-Za-z0-9.:_]*$`) are allowed, and they
declare a location-independent identifier (an anchor) for the schema. JSON
Pointer fragments such as `#/definitions/foo` are _not_ valid in
[`$id`]({{< ref "draft7/core/id" >}}), even though they are valid in
[`$ref`]({{< ref "draft7/core/ref" >}}). The behaviour of any other fragment
form is undefined.

This anchor-style usage of [`$id`]({{< ref "draft7/core/id" >}}) was later
replaced by the dedicated [`$anchor`]({{< ref "2019-09/core/anchor" >}})
keyword starting in JSON Schema 2019-09.

{{</common-pitfall>}}

{{<best-practice>}}

It is strongly recommended for every schema file to explicitly declare an
Expand Down
Loading