How do I validate a JSON Schema schema, in Python?

Question:

I am programmatically generating a JSON-Schema schema. I wish to ensure that the schema is valid. Is there a schema I can validate my schema against?

Please note my use of schema twice in that sentence and the title. I don’t want to validate data against my schema, I want to validate my schema.

Asked By: GDorn

||

Answers:

Using jsonschema, you can validate a schema against the meta-schema. The core meta-schema is here, but jsonschema bundles it so downloading it is unnecessary.

from jsonschema import Draft3Validator
my_schema = json.loads(my_text_file) #or however else you end up with a dict of the schema
Draft3Validator.check_schema(my_schema)
Answered By: GDorn
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.