$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)
Kind Identifier
Applies To Any
Base Dialect 2020-12
Changed In None
Introduced In 2019-09
Vocabulary Core
Specification https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.1.2
Metaschema https://json-schema.org/draft/2020-12/meta/core
Official Tests draft2020-12/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.

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.

Examples

The seven required vocabularies declared by the JSON Schema 2020-12 official dialect Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://json-schema.org/draft/2020-12/schema",
  "$dynamicAnchor": "meta",
  "$vocabulary": {
    "https://json-schema.org/draft/2020-12/vocab/core": true,
    "https://json-schema.org/draft/2020-12/vocab/applicator": true,
    "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
    "https://json-schema.org/draft/2020-12/vocab/validation": true,
    "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
    "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
    "https://json-schema.org/draft/2020-12/vocab/content": true
  },
  // ...
}
An example dialect meta-schema that opts-in to the JSON Schema 2020-12 format assertion vocabulary Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/2020-12-with-format-assertion",
  "$dynamicAnchor": "meta",
  "$vocabulary": {
    "https://json-schema.org/draft/2020-12/vocab/core": true,
    "https://json-schema.org/draft/2020-12/vocab/applicator": true,
    "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
    "https://json-schema.org/draft/2020-12/vocab/validation": true,
    "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
    "https://json-schema.org/draft/2020-12/vocab/format-assertion": true,
    "https://json-schema.org/draft/2020-12/vocab/content": true
  },
  "allOf": [
    { "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/unevaluated" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/validation" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/meta-data" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/content" }
  ]
}
An example dialect meta-schema that imports the Core vocabulary as required and the Validation vocabulary as optional Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/simple-2020-12",
  "$dynamicAnchor": "meta",
  "$vocabulary": {
    "https://json-schema.org/draft/2020-12/vocab/core": true,
    "https://json-schema.org/draft/2020-12/vocab/validation": false
  },
  "allOf": [
    { "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
    { "$ref": "https://json-schema.org/draft/2020-12/meta/validation" }
  ]
}