When to invoke
- You maintain APIs/events/config schemas and need to understand what changed between two JSON Schema documents.
- You want a machine-readable summary of breaking vs non-breaking changes.
Inputs needed
--old: Path to the previous JSON Schema (draft-07 style supported).--new: Path to the new JSON Schema.- Optional:
--out: Path to write a JSON report.
Workflow
- Load both schemas.
- Recursively index fields (JSON Pointer-like paths) for
type,required,enum, and objectproperties. - Compute added/removed/modified paths.
- Classify changes:
- Breaking: removed field, type change, required added, enum narrowed.
- Non-breaking: added optional field, required removed, enum widened, description/title-only updates.
- Emit a summary and detailed diff entries.
Output format
JSON object:
summary: counts for breaking/non_breaking/unknownbreaking: list of change objectsnon_breaking: list of change objectsunknown: list of change objects
Each change object includes: path, change_type, old, new, reason.
Guardrails
- Do not assume semantic compatibility beyond basic schema keywords; label ambiguous changes as
unknown. - Never modify input schemas.
- Treat missing
requiredas empty.
Reference code
Use json_schema_drift_detector.py.