I'm trying to validate my complex json schema definition file to be sure that there is no typo in the schema.
I use the jsonschema
script provided by python jsonschema library.
I use meta-schema files downloaded from json schema specification page.
I was downloaded the "Core/Validation Dialect meta-schema" file and all "Single-vocabulary meta-schemas", added the "json" extension and store these files in this structure:
├── meta
│ ├── applicator.json
│ ├── content.json
│ ├── core.json
│ ├── format-annotation.json
│ ├── format-assertion.json
│ ├── meta-data.json
│ ├── unevaluated.json
│ └── validation.json
└── schema.json
If I create this test01.json
file (notice the "objectx" typo on line 5):
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/sample/conf.schema.json",
"title": "Sample",
"type": "objectx",
"properties": {
"browser": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
then the validation fail (as expected):
$ jsonschema -i test01.json some/path/schema.json
objectx: 'objectx' is not valid under any of the given schemas
But when I make similar typo in embedded object (see line 8) in test02.json
:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/sample/conf.schema.json",
"title": "Sample",
"type": "object",
"properties": {
"browser": {
"type": "objectx",
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
then the validation pass (no output is printed):
$ jsonschema -i test02.json some/path/schema.json
How can I validate complex json schema document (not only the top level object) from CLI in linux?