Warning
JSON Schema Draft 3 and older are not supported at this point in time.
jsonschema metaschema [schemas-or-directories...]
[--http/-h] [--verbose/-v] [--debug/-g] [--extension/-e <extension>]
[--resolve/-r <schemas-or-directories> ...]
[--ignore/-i <schemas-or-directories>] [--trace/-t]
[--default-dialect/-d <uri>] [--json/-j]Ensure that a schema or a set of schemas are considered valid with regards to
their metaschemas. The --json/-j option outputs the evaluation result using
the JSON Schema
Basic
standard format.
Warning
The point of this command is to help schema writers make sure their schemas
are valid. As a consequence, this command prioritises useful error messages
and exhaustive evaluation rather than validation speed. If you require fast
validation, use the validate command with its
--fast/-f option instead.
The --resolve/-r option is crucial to import custom meta-schemas into the
resolution context, otherwise the validator won't know where to look for them.
To help scripts distinguish validation errors, these are reported using exit code 2.
For example, consider this fictitious JSON Schema that follows the Draft 4
dialect but sets the type property to an invalid value:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": 1
}Running the metaschema command on it will surface an error:
$ jsonschema metaschema schema.json
error: The target document is expected to be one of the given values
at instance location "/type"
at evaluate path "/properties/type/anyOf/0/$ref/enum"
error: Mark the current position of the evaluation process for future jumps
at instance location "/type"
at evaluate path "/properties/type/anyOf/0/$ref"
error: The target document is expected to be of the given type
at instance location "/type"
at evaluate path "/properties/type/anyOf/1/type"
error: The target is expected to match at least one of the given assertions
at instance location "/type"
at evaluate path "/properties/type/anyOf"
error: The target is expected to match all of the given assertions
at instance location ""
at evaluate path "/properties"jsonschema metaschema path/to/my/schema_1.json path/to/my/schema_2.jsonjsonschema validate path/to/my/schema.json --resolve path/to/custom-meta-schema.jsonjsonschema metaschema path/to/schemas/jsonschema metaschemajsonschema metaschema path/to/schemas/ --ignore path/to/schemas/nestedjsonschema metaschema --extension .schema.jsonjsonschema metaschema path/to/my/schema.json --tracejsonschema metaschema path/to/my/schema.json --json