You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/2019-09/core/vocabulary.markdown
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
keyword: "$vocabulary"
3
3
signature: "Object<URI, Boolean>"
4
4
value: This keyword must be set to an object where each key is a JSON Schema vocabulary URI and each value is a boolean that represents whether the corresponding vocabulary is considered optional (false) or required (true)
5
-
summary: "This keyword is used in meta-schemas to identify the required and optional vocabularies available for use in schemas described by that meta-schema."
5
+
summary: "This keyword is used in dialect meta-schemas to identify the required and optional vocabularies available for use in schemas described by that dialect."
Copy file name to clipboardExpand all lines: content/2020-12/core/vocabulary.markdown
+41-53Lines changed: 41 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
keyword: "$vocabulary"
3
3
signature: "Object<URI, Boolean>"
4
4
value: This keyword must be set to an object where each key is a JSON Schema vocabulary URI and each value is a boolean that represents whether the corresponding vocabulary is considered optional (false) or required (true)
5
-
summary: "This keyword is used in meta-schemas to identify the required and optional vocabularies available for use in schemas described by that meta-schema."
5
+
summary: "This keyword is used in dialect meta-schemas to identify the required and optional vocabularies available for use in schemas described by that dialect."
The `$vocabulary` keyword is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. It is also used to indicate whether each vocabulary is required or optional, in the sense that an implementation must understand the required vocabularies in order to successfully process the schema.
22
+
The `$vocabulary` keyword is a _mandatory_ component of a dialect meta-schema
23
+
to list the required and optional vocabularies available for use by the schema
24
+
instances of such dialect. The vocabularies declared by a dialect meta-schema
25
+
are not inherited by meta-schemas that derive from it. Each dialect meta-schema
26
+
must explicitly state the vocabularies it imports using the `$vocabulary`
27
+
keyword.
23
28
24
-
***Required and optional vocabularies:** If a vocabulary is required and an implementation does not recognize it, it must refuse to process any schemas that declare this meta-schema. If a vocabulary is optional, implementations that do not recognize it should proceed with processing such schemas.
29
+
{{<common-pitfall>}}Declaring the `$vocabulary` keyword in a schema does not
30
+
grant that same schema access to such vocabularies. Instead, the `$vocabulary`
31
+
keyword must be set in the dialect meta-schema that describes the desired
32
+
schema.{{</common-pitfall>}}
25
33
26
-
***Mandatory:** The Core vocabulary MUST always be included and set as required.
34
+
If a vocabulary is marked as required, JSON Schema implementations that do not
35
+
recognise the given vocabulary must refuse to process schemas described by such
36
+
dialect. As a notable exception, every dialect must list the [Core](..)
37
+
vocabulary as required, as it is the foundational vocabulary that implements
38
+
the vocabulary system itself.
27
39
28
-
***Non-inheritability:** Vocabularies defined in one meta-schema do not automatically apply to another meta-schema that references it. Each meta-schema must declare its vocabularies independently.
29
-
30
-
***Recommendation:** Meta-schemas should always declare this keyword to clearly specify the vocabularies in use and avoid ambiguities.
40
+
{{<learning-more>}} By convention, every official JSON Schema dialect defines a
41
+
dynamic anchor called `meta`. This serves as an extensibility point for
42
+
arbitrary vocabularies to register syntactic constraints that are automatically
43
+
applied to every JSON Schema subschema apart from the top-level one.
44
+
{{</learning-more>}}
31
45
32
46
## Examples
33
47
34
-
{{<schema `'$vocabulary' for default official-2020-12 meta-schema`>}}
48
+
{{<schema `The seven required vocabularies declared by the JSON Schema 2020-12 official dialect`>}}
The `$dynamicAnchor: meta` declaration is set by convention to `meta` on the official meta-schemas. This setting serves as a mechanism to enable meta-schema extensibility. By declaring `$dynamicAnchor: meta` here, JSON Schema is configured to validate every subschema of the instance schema against the meta-schema, extending validation beyond just the top level.
78
-
{{</learning-more>}}
79
-
80
-
{{<schema `Meta-schema with the above vocabulary as required`>}}
0 commit comments