Skip to main content

Convert JSON Schema to Pydantic models

Project description

schema2model

Convert JSON Schema dictionaries to Pydantic models.

Installation

pip install schema2model

Usage

from schema2model import schema2model

schema = {
    "title": "User",
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer"}
    },
    "required": ["name", "age"]
}

User = schema2model(schema)
user = User(name="Alice", age=30)

Supported Features

  • Basic types: str, int, float, bool
  • Collections: list, set, tuple, dict
  • Date/time: datetime, date, time, timedelta
  • Special types: UUID, bytes, AnyHttpUrl
  • Nested models and enums
  • Recursive models
  • RootModel
  • Discriminated unions
  • Field constraints (gt, lt, min_length, pattern, etc.)
  • Field metadata (description, examples, deprecated)

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

schema2model-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

schema2model-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: schema2model-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for schema2model-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02e4dc422a97eb54cff3c0ccfc97bf7b9d09267a8a6fcb7ca84eeeaf88bc22f3
MD5 3d4250a5cd4b2fe77ac1d301fac48772
BLAKE2b-256 7111e72db07a979c5bdccab9e6d45ec27542c9bba96be9a250dbd96d381eb291

See more details on using hashes here.

Provenance

The following attestation bundles were made for schema2model-0.1.0.tar.gz:

Publisher: main.yml on tillahoffmann/schema2model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: schema2model-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for schema2model-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 629142d66df7a5f7b62c665341744c636fdef055fd2640a5bb407b1d5cbd11ae
MD5 5046ddda4ba33e381eb7a66a3e1eaeef
BLAKE2b-256 cb686ef97a44d670a0b89ec96368e6f74d1c77f70dbed1bd62a297ad357be5cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for schema2model-0.1.0-py3-none-any.whl:

Publisher: main.yml on tillahoffmann/schema2model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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