Parsdantic is a powerful Python package that automatically generates Pydantic models from JSON schemas. Enums support **included**
Project description
Parsdantic
Parsdantic is a powerful Python package that automatically generates Pydantic models from JSON schemas. It simplifies the process of data validation and serialization by bridging the gap between JSON Schema and Pydantic. Features
Features
- Convert JSON schemas to Pydantic models with a single function call
- Support for nested objects and complex data structures
- Automatic type inference and validation
Installation
You can install Parsdantic using pip:
pip install parsdantic
Quick Start
Here's a simple example of how to use Parsdantic:
from parsdantic.parser import parse
schema = {
"$defs": {
"Person": {
"properties": {
"id": {"title": "Id", "type": "integer"},
"name": {"title": "Name", "type": "string"},
"directions": {
"items": {"type": "string"},
"title": "Directions",
"type": "array"
}
},
"required": ["id", "name", "directions"],
"title": "Person",
"type": "object"
}
},
"properties": {
"people": {
"items": {"$ref": "#/$defs/Person"},
"title": "People",
"type": "array"
}
},
"required": ["people"],
"title": "People",
"type": "object"
}
People = parse(schema)
instance = People(
people=[
{"id": 1, "name": "John", "directions": ["Carrer de les Corts, 1", "Barcelona"]},
{"id": 2, "name": "Jane", "directions": ["Carrer de les Corts, 2", "Barcelona"]},
]
)
print(instance) # People(people=[Person(id=1, name='John', directions=['Carrer de les Corts, 1', 'Barcelona']), Person(id=2, name='Jane', directions=['Carrer de les Corts, 2', 'Barcelona'])])
Note: descriptions, default values, required fields, and Enum types are still not supported.
Support
You can open an issue on the GitHub issue tracker.
LICENSE
This project is licensed under the MIT License. See the LICENSE file for details.
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
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 parsdantic-0.2.0.tar.gz.
File metadata
- Download URL: parsdantic-0.2.0.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
668105b8683aeb0c22a13acd68e3c4cab830d25427a8f394b0817669e4b31556
|
|
| MD5 |
30f9fc4d2d0114a97e3b3765cdafe4d0
|
|
| BLAKE2b-256 |
0523339cf759ac63a97c97faf83f4134e41756b34f508d4526fee34e8d067c65
|
File details
Details for the file parsdantic-0.2.0-py3-none-any.whl.
File metadata
- Download URL: parsdantic-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8b68a2e6771cf35f3a66cf0ef086bb318d747cc68887db7225accdc096b6082
|
|
| MD5 |
b4a2c3a737afe407274ecaa9ee9c05bb
|
|
| BLAKE2b-256 |
e16b395ff6bd98dd77818c0364d0b1714db8d8d900610086ee26635a3a999e35
|