Python Interface¶
To quickly compare schemas and print the result to the console:
from jsonschema_diff import JsonSchemaDiff, ConfigMaker
from jsonschema_diff.color import HighlighterPipeline
from jsonschema_diff.color.stages import (
MonoLinesHighlighter, PathHighlighter, ReplaceGenericHighlighter,
)
prop = JsonSchemaDiff(
config=ConfigMaker.make(),
colorize_pipeline=HighlighterPipeline([
MonoLinesHighlighter(),
ReplaceGenericHighlighter(),
PathHighlighter(),
])
)
prop.compare( # Function accepts both file path and schema dict itself // can be combined
old_schema="context.old.schema.json",
new_schema="context.new.schema.json"
)
# Теперь можно вывести
prop.print(with_legend=True)
See also for more: jsonschema_diff.pypi_interface