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

你。 提交于 2020-01-22 08:23:32

问题


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.


回答1:


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)


来源:https://stackoverflow.com/questions/13812136/how-do-i-validate-a-json-schema-schema-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!