Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command-line validate with a schema reference #6

Open
petsuter opened this issue Aug 5, 2015 · 0 comments
Open

Command-line validate with a schema reference #6

petsuter opened this issue Aug 5, 2015 · 0 comments

Comments

@petsuter
Copy link

petsuter commented Aug 5, 2015

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant