$vocabulary keyword is used in meta-schemas to declare which vocabularies are available and whether they are required or optional for schemas using that meta-schema.
Syntax
An object where each property name is a vocabulary IRI and each value is a boolean indicating whether the vocabulary is required (true) or optional (false).
Purpose
The$vocabulary keyword enables:
- Vocabulary Declaration: Explicitly states which keyword vocabularies a meta-schema supports
- Requirement Specification: Indicates whether implementations must support each vocabulary
- Extension Management: Controls which keywords are available in schemas that use the meta-schema
Usage
Format
Required vs Optional Vocabularies
- Required (
true): Implementations MUST support this vocabulary to process schemas using this meta-schema. Vocabularies omitted from$vocabularyMUST NOT be available. - Optional (
false): Implementations MAY support this vocabulary. If unsupported, keywords from this vocabulary are treated according to the implementation’s handling of unrecognized keywords.
Examples
Meta-Schema with Standard Vocabularies
Custom Meta-Schema with Extension
Vocabulary Control
Standard Keywords
Standard keywords are only available as vocabulary keywords and are subject to$vocabulary control. This means:
- Keywords from vocabularies not listed in
$vocabularyare not available - Implementations must check vocabulary support before processing schemas
- Unknown required vocabularies should cause schema processing to fail
Extension Keywords
Extension keywords (those not in standard vocabularies) are handled differently:- Keywords beginning with
x-are implicitly annotation keywords - Other extension keywords require explicit vocabulary declaration
- Unrecognized keywords cause implementations to refuse evaluation
Meta-Schema Context
The$vocabulary keyword is primarily used in meta-schemas, not in regular schemas. A meta-schema is a schema that validates other schemas and defines which keywords those schemas can use.
Regular schemas typically don’t use $vocabulary directly. Instead, they use $schema to reference a meta-schema that declares its vocabularies.