I'm looking for a Python module for loading a JSON Schema file and handling it as an object. I can do this via the regular json
module and e.g. dictor
, but I was hoping to find a JSON Schema specific module that can e.g. natively understand dependencies
, definitions
and similar concepts, providing more easy handling of the data.
To be clear, I'm not looking for a JSON Schema validation tool - but rather a JSON Schema object manager. Does something like this exist?
To illustrate the type of processing I'm looking to do, see below:
def schema_lister(device,schema, path):
path_conf = Path(__file__).resolve().parent.parent
schema_dir = f"_static/tmp/{device}_schema.json"
path_schema = Path(path_conf,schema_dir)
with open(path_schema) as json_file:
schema_json = json.load(json_file)
json_file.close()
schema = dictor(schema_json,path)
for elm in schema:
elm_schema = dictor(schema,elm)
if elm != 'anyOf' and elm != 'dependencies' and isinstance(elm_schema, dict):
# do things, e.g. print title, description etc.
I ended up using sphinx-jsonschema
for this purpose.