Skip to main content

jsonschema-changelog

CI Coverage PyPI version Python versions License: MIT

Detect, document, and manage changes between JSON Schema versions.

Part of the Búho Zurdo ecosystem 🦉


Overview

jsonschema-changelog provides deterministic semantic comparison, classification, and changelog generation for JSON Schema specifications.

  • Detect differences between schema revisions (properties, types, constraints, enums, conditional subschemas if/then/else, dependentRequired, and dynamic keywords like unevaluatedProperties).
  • Classify changes by operational impact (breaking, non-breaking, deprecations).
  • Generate human-readable and machine-parseable changelogs (Markdown, JSON, HTML).
  • Validate backward and forward schema compatibility in CI/CD pipelines.
  • Generate deterministic data migration scripts.

Designed for data governance in schema-driven architectures, APIs, and clinical/laboratory management systems (LIMS).


Installation

pip install jsonschema-changelog

For development:

git clone https://github.com/buhozurdo/jsonschema-changelog.git
cd jsonschema-changelog
pip install -e ".[dev]"

Quick Start

Python API

from jsonschema_changelog import SchemaDiff, ChangeClassifier, ChangelogGenerator

old_schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "status": {"type": "string", "enum": ["active", "inactive"]}
    },
    "required": ["name"]
}

new_schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "status": {"type": "string", "enum": ["active", "inactive", "pending"]},
        "email": {"type": "string", "format": "email"}
    },
    "required": ["name"]
}

# 1. Detect differences
differ = SchemaDiff(old_version="1.0.0", new_version="2.0.0")
diff_result = differ.compare(old_schema, new_schema)

# 2. Classify impact
classifier = ChangeClassifier()
classification = classifier.classify(diff_result)

print(f"Breaking: {len(classification.breaking_changes)}")
print(f"Non-breaking: {len(classification.non_breaking_changes)}")
print(f"Compatible: {classification.is_compatible}")

# 3. Generate changelog
generator = ChangelogGenerator(title="API Schema Changelog")
changelog = generator.generate(classification)
markdown = generator.to_markdown(changelog)
print(markdown)

Command Line Interface

# Compare schemas
jsonschema-changelog diff old.json new.json

# Generate changelog
jsonschema-changelog changelog old.json new.json --format markdown -o CHANGELOG.md

# Validate compatibility (fails with exit code 1 on breaking changes)
jsonschema-changelog validate old.json new.json --fail-on-breaking

# Generate data migration script
jsonschema-changelog migrate old.json new.json --language python -o migrate.py

# Inspect schema details
jsonschema-changelog info schema.json

Change Classification Matrix

Impact Description Examples
🚨 Breaking Incompatible contract change Property removed, field made required, enum value removed, constraint narrowed (minimum increased).
✨ Non-Breaking Backward-compatible addition Optional property added, required field made optional, enum value added, constraint relaxed.
⚠️ Deprecation Marked for future removal Field annotated with deprecated: true or notice in description.
📝 Documentation Metadata update Changes to title, description, or examples without structural impact.

CI/CD Integration

GitHub Actions (Fail PR on Breaking Changes)

name: Schema Compatibility Check

on:
  pull_request:
    paths:
      - 'schemas/**'

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - run: pip install jsonschema-changelog

      - name: Validate schema compatibility
        run: |
          jsonschema-changelog validate \
            schemas/current.json \
            schemas/proposed.json \
            --fail-on-breaking

      - name: Generate changelog
        if: always()
        run: |
          jsonschema-changelog changelog \
            schemas/current.json \
            schemas/proposed.json \
            --format markdown \
            -o SCHEMA_CHANGELOG.md

      - uses: actions/upload-artifact@v4
        with:
          name: schema-changelog
          path: SCHEMA_CHANGELOG.md

Pre-commit Hook

repos:
  - repo: local
    hooks:
      - id: schema-compatibility
        name: Validate Schema Compatibility
        entry: jsonschema-changelog validate
        language: python
        files: \.json$
        args: ['schemas/current.json', 'schemas/proposed.json', '--fail-on-breaking']

Known Limitations

  • Recursive Schemas: Self-referential $ref definitions beyond 10 levels of nesting are truncated to avoid recursion exhaustion.
  • Draft 2020-12 & OpenAPI 3.1 Support: The library provides broad support for modern JSON Schema keywords (including unevaluatedProperties, unevaluatedItems, dependentRequired, and if/then/else). However, highly complex dynamic cross-references or niche schema compositions might still fall back to structural diffs.

Testing

# Run test suite
pytest

# Run tests with coverage
pytest --cov=src/jsonschema_changelog --cov-report=term-missing

Contributing

Contributions are welcome. Please read CONTRIBUTING.md and adhere to Búho Zurdo Engineering Standards.

  1. Fork repository.
  2. Create feature branch (git checkout -b feat/schema-feature).
  3. Add tests and verify formatting.
  4. Open Pull Request.

License

MIT License. See LICENSE for details.

Metadata

Release files for jsonschema-changelog 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema-changelog 0.2.0
File Size Uploaded
jsonschema_changelog-0.2.0.tar.gz 40.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema-changelog 0.2.0
File Interpreter ABI Platform
jsonschema_changelog-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.6 kB

Release files / jsonschema_changelog-0.2.0.tar.gz

Download URL jsonschema_changelog-0.2.0.tar.gz
Size 40.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0e7f2d55f4eabd17b53b159ec26c2b456b562ebb97c10a141fa69516931906cb
BLAKE2b-256 checksum
How to use checksums
0cc16578d7069636a3b44903540589e79089bd372ab871882dfcfdc6f732cc8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / jsonschema_changelog-0.2.0-py3-none-any.whl

Download URL jsonschema_changelog-0.2.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4495c953c6896502acd435cf8ed629a330575e24945106df3d0b78bc8a962ffa
BLAKE2b-256 checksum
How to use checksums
3386a399e4d41da2d12b457d13eff63395aae596dc4aef8ca41f1968148ffd5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page