Skip to main content

Convert jsonschema to pydantic model

Project description

jsonschema2pydantic

Convert jsonschema to pydantic model

Installation

pip install jsonschema2pydantic

Examples

from pydantic import BaseModel
from jsonschema2pydantic import generate_schema

class Model(BaseModel):
    field_1: str
    field_2: int
    field_2: bool

DynamicModel = generate_schema({
  "properties": {
    "field_1": {
      "title": "Field 1",
      "type": "string"
    },
    "field_2": {
      "title": "Field 2",
      "type": "boolean"
    }
  },
  "required": [
    "field_1",
    "field_2"
  ],
  "title": "Model",
  "type": "object"
})

assert Model.model_json_schema() == DynamicModel.model_json_schema()

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

jsonschema2pydantic-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

jsonschema2pydantic-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jsonschema2pydantic-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for jsonschema2pydantic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8de6e1e12ea87ae096cbfdd648825e118975c18e026b19e0cae1f9f325424d3e
MD5 345883ed9b190039741038826fdde3fd
BLAKE2b-256 445628d990b7f8eb62a0fb3e4f2ceef1e10dd50d268f0ea22632619555c78ed1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jsonschema2pydantic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 696eb6419465625e9016d85da7fccf165c0e8b64a5fbca130cd9b6198d86d96d
MD5 d82c076bc57fc7060bf7258f18de148d
BLAKE2b-256 5dc1b1b7647667347cdedb1da21f29214a73642a41756202f25642d755aa8232

See more details on using hashes here.

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