$vocabulary : Object<URI, Boolean>
$vocabulary
Object<URI, Boolean>This keyword is used in dialect meta-schemas to identify the required and optional vocabularies available for use in schemas described by that dialect.
| 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)
Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
|
|---|---|
| Kind | Identifier |
| Applies To | Any |
| Base Dialect | 2019-09 |
| Changed In | None |
| Introduced In | 2019-09 |
| Vocabulary | Core |
| Specification | https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#rfc.section.8.1.2 |
| Metaschema | https://json-schema.org/draft/2019-09/meta/core |
| Official Tests | draft2019-09/vocabulary.json |
| Default | Implementation dependent |
| Annotation | None |
| Affected By | None |
| Affects | None |
| Also See |
The $vocabulary keyword is a
mandatory component of a dialect meta-schema to list the required and optional
vocabularies available for use by the schema instances of such dialect. The
vocabularies declared by a dialect meta-schema are not inherited by meta-schemas
that derive from it. Each dialect meta-schema must explicitly state the
vocabularies it imports using the $vocabulary keyword.
Common Pitfall
Declaring the $vocabulary keyword in a schema does not grant that same
schema access to such vocabularies. Instead, the $vocabulary keyword must be set in the dialect meta-schema
that describes the desired schema.
If a vocabulary is marked as required, JSON Schema implementations that do not recognise the given vocabulary must refuse to process schemas described by such dialect. As a notable exception, every dialect must list the Core vocabulary as required, as it is the foundational vocabulary that implements the vocabulary system itself.
Digging Deeper
By convention, every official JSON Schema dialect defines a recursive anchor at its root. This serves as an extensibility point for arbitrary vocabularies to register syntactic constraints that are automatically applied to every JSON Schema subschema apart from the top-level one.
Examples
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://json-schema.org/draft/2019-09/schema",
"$recursiveAnchor": true,
"$vocabulary": {
"https://json-schema.org/draft/2019-09/vocab/core": true,
"https://json-schema.org/draft/2019-09/vocab/applicator": true,
"https://json-schema.org/draft/2019-09/vocab/validation": true,
"https://json-schema.org/draft/2019-09/vocab/meta-data": true,
"https://json-schema.org/draft/2019-09/vocab/format": false,
"https://json-schema.org/draft/2019-09/vocab/content": true
},
// ...
}{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://example.com/simple-2019-09",
"$recursiveAnchor": true,
"$vocabulary": {
"https://json-schema.org/draft/2019-09/vocab/core": true,
"https://json-schema.org/draft/2019-09/vocab/validation": false
},
"allOf": [
{ "$ref": "https://json-schema.org/draft/2019-09/meta/core" },
{ "$ref": "https://json-schema.org/draft/2019-09/meta/validation" }
]
}