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.1.tar.gz
(31.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonschema2pydantic-0.1.1.tar.gz.
File metadata
- Download URL: jsonschema2pydantic-0.1.1.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4681c6582f5e3f24a4698d08485c7060aca107925ece60cea0f8942f2731aff
|
|
| MD5 |
9b3e4a0e55c8f313d78dba7535d1b053
|
|
| BLAKE2b-256 |
1cc6b516e2b8e020a7b3a8adf33626211b055b1196f967556ef9d5436d6cbf9e
|
File details
Details for the file jsonschema2pydantic-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jsonschema2pydantic-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d60e81046c74dab540b9249386b88db4d70a941730482b6f7131b07424538a4
|
|
| MD5 |
d7caea02ea3caab134902552153c9e97
|
|
| BLAKE2b-256 |
c2f3f7185c982c4d651a7815b668a901a6cf48f523f35ca21d9c7943b2d5a7d1
|