Skip to main content

Convert JSON Schemas to Pydantic models

Project description

jsonschema-pydantic

Simple transform of jsonschema to pydantic models.

Supported jsonschema features

  • primitive types
  • objects
  • arrays
  • nested objects
  • optional fields
  • default values

Install

pip install jsonschema-pydantic

Usage

from jsonschema_pydantic import jsonschema_to_pydantic

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

pydantic_model = jsonschema_to_pydantic(jsonschema)

Development

Run pytest test suite:

make test

Linting

Run all linters

make lint

Formatting

Format python code:

make fmt

Documentation

Generate documentation:

make docs

Contributions

Read the CONTRIBUTING.md file.

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

jsonschema_pydantic-0.6.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

jsonschema_pydantic-0.6-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

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