Skip to main content

isjsonschemasubset

Check one JSONSchema is a subset of another. Plays nicely with Pydantic.

Install

pip install isjsonschemasubset

Currently in an Alpha.

Usage

from pathlib import Path
from isjsonschemasubset import dump, issubset, load

path_to_a = Path(__file__).parent / "a.json"
path_to_b = Path(__file__).parent / "b.json"
dump(A, path_to_a)  # where A is a `type[pydantic.BaseModel]`
dump(B, path_to_b)  # where B is a `type[pydantic.BaseModel]`
json_schema_a = load(path_to_a)
json_schema_b = load(path_to_b)

for error in issubset(json_schema_a, json_schema_b):
    ...

Yields errors if type A is not a subset of B.

In this context, "is a subset of" means that if we were to do:

B(**a.model_dump(mode="json"))

We would not get an error. This is very important when deserializing data from JSON columns in the database and for writing backwards compatible APIs.

See tests/test_schema_versions.py for further example usage. In this case, every time we change Foo (or anything that Foo refers to recursively), we dump a new schema in tests/schemas/Foo and check all of the schemas are backwards compatible.

Dev install

git clone git@github.com:leontrolski/isjsonschemasubset.git
pip install -r requirements-dev.txt
pytest
mypy src tests --strict

Upload to pypi

# bump version
python -m pip install build twine
python -m build
twine check dist/*
twine upload dist/*

Metadata

Release files for isjsonschemasubset 0.0.2

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

Source distribution (sdist)

Source distribution for isjsonschemasubset 0.0.2
File Size Uploaded Provenance
isjsonschemasubset-0.0.2.tar.gz 6.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for isjsonschemasubset 0.0.2
File Interpreter ABI Platform
isjsonschemasubset-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / isjsonschemasubset-0.0.2.tar.gz

Download URL isjsonschemasubset-0.0.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4fd22abf1963c51bcd301f6cb0be484a1a0b440a83f2eb52889483ca880c6979
BLAKE2b-256 checksum
How to use checksums
5d8e66e5f11ac5dc6c12551b5f85ec223c871a8228a7ed88bd46d09fd16ae5c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / isjsonschemasubset-0.0.2-py3-none-any.whl

Download URL isjsonschemasubset-0.0.2-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d16ed09ece947205c9e824b776ea9f880c67ebce52219dad9b13a539539f174
BLAKE2b-256 checksum
How to use checksums
dd992289bd8be3057ea21e5c4299052ef6f32b1e687efc5bab1bac0da2f6ef20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for isjsonschemasubset 0.0.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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