Skip to main content

Synchronise Pydantic model schemas with JSONSchema files

Project description

pydantic-schema-sync

Synchronise Pydantic model schemas with JSONSchema files.

Usage

Python

From a model class:

from pydantic_schema_sync import sync_schema

# Using field alias (default)
sync_schema(model=Foo, schema_path="schema.json")

# Unaliased field
sync_schema(model=Foo, schema_path="schema.json", mjs_kwargs={"by_alias": False})

From a path to a model class:

from pydantic_schema_sync import sync_schema_from_path

# This path must be in an installed package
path_to_model_cls = "pydantic_schema_sync.cli.SyncCLI"
sync_schema_from_path(model=path_to_model_cls, schema_path="schema.json")

CLI

To serialise the schema of the model named ExampleModel (in the package my_pkg's module my_module) to the file test.json, passing the by_alias=False param to .model_json_schema():

model-schema-sync \
  --model my_pkg.my_module.ExampleModel \
  --schema_path test.json \
  --mjs_kwargs '{"by_alias":false}'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_schema_sync-0.1.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

pydantic_schema_sync-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_schema_sync-0.1.0.tar.gz.

File metadata

  • Download URL: pydantic_schema_sync-0.1.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.1 CPython/3.10.14 Linux/5.15.0-117-generic

File hashes

Hashes for pydantic_schema_sync-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0bbc4a5782a6f05f1f990d9c3dc71abd34040dbc30eb08128ef2b70da148d781
MD5 75c869fd7c020c666f95a2401dcb4586
BLAKE2b-256 a76c8d620044bee17996e882824d9e3624da0b86c74b60d2882a5556d4156a4f

See more details on using hashes here.

File details

Details for the file pydantic_schema_sync-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_schema_sync-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e775714cd1575739836e452e40635a4388f464d6bbf7f32409c2383bfc23411b
MD5 580e5950e7b4769a735476906dd1ca5b
BLAKE2b-256 9ee16975ab9b183135b59c8ee19cc8841b3c5d91d6ea296b3fe6077df1b13600

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page