jsonschema_diff.cli

A tiny command-line front-end around jsonschema_diff that highlights semantic differences between two JSON-Schema documents directly in your terminal.

Typical usage

>>> jsonschema-diff old.schema.json new.schema.json
>>> jsonschema-diff --no-color --legend old.json new.json
>>> jsonschema-diff --exit-code old.json new.json  # useful in CI

Exit status

  • 0 – the two schemas are semantically identical

  • 1 – at least one difference was detected (only when --exit-code is given)

The CLI is intentionally minimal: all comparison options are taken from jsonschema_diff.ConfigMaker(), so the behaviour stays in sync with the library defaults.

Functions

main(→ None)

CLI entry-point (invoked by python -m jsonschema_diff or by the

Module Contents

main(argv: list[str] | None = None) None[source]

CLI entry-point (invoked by python -m jsonschema_diff or by the jsonschema-diff console script).

Parameters:

argv – Command-line argument vector excluding the executable name. When None (default) sys.argv[1:] is used – this is the behaviour required by setuptools console-scripts.

Note

The function performs four sequential steps:

  1. Build a JsonSchemaDiff instance.

  2. Compare the two user-supplied schema files.

  3. Print a colourised diff (optionally with a legend).

  4. Optionally exit with code 1 if differences are present.