1

Are there any python libraries or tools that check if a JSON schema is valid?

I do not want to validate an instance against a JSON schema, but I would like to check if the JSON schema itself is valid or not. For example, if all the required fields are specified or not, or whether the data types are valid types or not.

I already had a look at check_schema() from jsonschema library, but this library does not check the aspects that I have mentioned above.

4

1 回答 1

2

You can use a schema validator for validating schemas. There are special schemas called meta-schemas, that validate other "normal" schemas (and themself). For the json schema specification, you can download such meta-schemas from the specification webpage.

There you can download the "Core/Validation Dialect meta-schema". You then can validate any other json schema with

$ jsonschema -i your_specific_schema.json meta_schema.json

Of cource you can also use it in your python code.

于 2022-01-12T08:50:18.527 回答