Command-line validate with a schema reference
petsuter opened this issue · 0 comments
petsuter commented
Could a --schema-pointer <pointer>
parameter be added to json-validate
?
I would like to validate various similar JSON file with just one schema file containing various related schema definitions.
Example:
- foo.json contains
{foo:3}
- foo_bar.json contains
{foo:3, bar:4}]
- foos.json contains
[{foo:3}, {foo:4}]
- schema.json contains:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"foo": {
"type": "object",
"properties": {
"foo": { "type": "integer" }
},
"required": ["foo"]
},
"foo_bar": {
"allOf": [
{ "$ref": "#/definitions/foo" },
{
"properties": {
"bar": { "type": "integer" }
},
"required": ["bar"]
}
]
},
"foos": {
"type": "array",
"items": { "$ref": "#/definitions/foo" }
}
}
}
$ json-validate --schema-file=schema.json --schema-pointer=/definitions/foo --document-file=foo.json
$ json-validate --schema-file=schema.json --schema-pointer=/definitions/foo_bar --document-file=foo_bar.json
$ json-validate --schema-file=schema.json --schema-pointer=/definitions/foos --document-file=foos.json