JSON Schema Auditor is a command-line tool that inspects a JSON Schema file and reports the keywords and data types used. It supports complex schemas, including nested properties, definitions, and conditionals (if
, then
, else
).
Important
The tool does not resolve $ref
s outside of the specified JSON Schema file. If your schema file references other schema files, you need to run the tool against each schema file.
- Analyze Keywords: Identifies all JSON Schema keywords used in a given schema.
- Extract Data Types: Lists all data types (
string
,integer
, etc.) defined in the schema. - Supports Nested Structures: Handles deeply nested properties,
definitions
,$defs
, and conditionals. - JSON Schema Compatibility: Compatible with JSON Schema Draft 4 and later.
Clone the repository and install the dependencies:
git clone https://github.com/OpenDataServices/json-schema-auditor.git
cd json-schema-auditor
pip install -r requirements.txt
Run the command with the path to your JSON Schema file:
python audit_json_schema.py <file_path>
file_path
: The path to the JSON Schema file you want to audit.
Given the following schema file example_schema.json
:
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" },
"address": {
"type": "object",
"properties": {
"street": { "type": "string" },
"city": { "type": "string" }
}
}
},
"definitions": {
"example": {
"type": "object",
"properties": {
"id": { "type": "string" }
}
}
}
}
Run the tool:
python audit_json_schema.py example_schema.json
Output:
Keywords used in the schema:
definitions, properties, type
Types used in the schema:
integer, object, string
Contributions are welcome! Please submit a pull request or open an issue for feature requests and bug reports.
- Fork the repository.
- Create a feature branch.
- Make your changes and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Author: @duncandewhurst
Feel free to reach out with questions or suggestions!