jsonschema_diff

Submodules

Classes

ConfigMaker

Helper that builds a fully populated Config.

JsonSchemaDiff

Facade around the low-level diff engine.

Package Contents

class ConfigMaker[source]

Helper that builds a fully populated Config.

static make(
*,
tab_size: int = 2,
path_render_with_properies: bool = False,
path_render_with_items: bool = False,
list_comparator: bool = True,
range_digit_comparator: bool = True,
range_length_comparator: bool = True,
range_items_comparator: bool = True,
range_properties_comparator: bool = True,
additional_compare_rules: jsonschema_diff.core.tools.compare.COMPARE_RULES_TYPE = {},
additional_combine_rules: jsonschema_diff.core.tools.combine.COMBINE_RULES_TYPE = [],
additional_pair_context_rules: jsonschema_diff.core.tools.context.PAIR_CONTEXT_RULES_TYPE = [],
additional_context_rules: jsonschema_diff.core.tools.context.CONTEXT_RULES_TYPE = {},
additional_path_maker_ignore: jsonschema_diff.core.tools.render.PATH_MAKER_IGNORE_RULES_TYPE = [],
) Config[source]

Assemble and return a Config.

Parameters:
  • tab_size (int) – Number of spaces per indentation level.

  • path_render_with_properies (bool) – Include these schema service tokens in rendered paths.

  • path_render_with_items (bool) – Include these schema service tokens in rendered paths.

  • list_comparator (bool) – Enable CompareList.

  • range_*_comparator (bool) – Enable CompareRange for numeric/length/items/properties limits.

  • additional_* (collections) – User-supplied rules that override the built-ins.

class JsonSchemaDiff(
config: Config,
colorize_pipeline: HighlighterPipeline,
legend_ignore: list[type[Compare]] | None = None,
)[source]

Facade around the low-level diff engine.

Call sequence

  1. compare() or compare_from_files()

  2. render() → string (kept in last_render_output)

  3. legend() → legend table (uses last_compare_list)

config: Config
colorize_pipeline: HighlighterPipeline
table_maker: LegendRenderer
legend_ignore: list[type[Compare]] = []
last_render_output: str = ''
last_compare_list: list[type[Compare]] = []
static fast_pipeline(
config: Config,
old_schema: dict | str,
new_schema: dict | str,
colorize_pipeline: HighlighterPipeline | None,
) tuple[str, list[type[Compare]]][source]

One-shot utility: compare old_schema vs new_schema and return (rendered_text, compare_list).

Accepted formats: dict or path to JSON file.

compare(
old_schema: dict | str,
new_schema: dict | str,
) JsonSchemaDiff[source]

Populate internal Property tree and perform comparison.

Accepted formats: dict or path to JSON file.

rich_render() Text[source]

Return the diff body ANSI-colored.

Side effects

  • self.last_render_output – cached rendered text.

  • self.last_compare_list – list of Compare subclasses encountered.

render() str[source]

Return the diff body ANSI-colored.

Side effects

  • self.last_render_output – cached rendered text.

  • self.last_compare_list – list of Compare subclasses encountered.

rich_legend(
comparators: list[type[Compare]],
) Table[source]

Return a legend table filtered by self.legend_ignore.

legend(
comparators: list[type[Compare]],
) str[source]

Return a legend table filtered by self.legend_ignore.

print(
*,
with_body: bool = True,
with_legend: bool = True,
) None[source]

Pretty-print the diff and/or the legend.

Parameters:
  • colorized (bool) – Apply ANSI colors to both body and legend.

  • with_body (bool) – Toggle respective sections.

  • with_legend (bool) – Toggle respective sections.