Dynamically generate pydantic models from JSON schema.
Project description
dydantic
Dydantic is a Python library for dynamically generating Pydantic models from JSON schemas. It provides a convenient way to create Pydantic models on-the-fly based on the structure defined in a JSON schema.
Features
- Automatically generate Pydantic models from JSON schemas
- Support for nested objects and referenced definitions
- Customizable model configurations, base classes, and validators
- Handle various JSON schema types and formats
- Extensible and flexible API
Installation
You can install dydantic using pip:
pip install -U dydantic
Usage
Here's a simple example of how to use dydantic to create a Pydantic model from a JSON schema:
from dydantic import create_model_from_schema
json_schema = {
"title": "Person",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name"],
}
Person = create_model_from_schema(json_schema)
person = Person(name="John", age=30)
print(person) # Output: Person(name='John', age=30)
For more advanced usage and examples, please refer to the documentation.
Documentation
The complete documentation for dydantic can be found at: https://dydantic.readthedocs.io/
The documentation provides detailed information on installation, usage, API reference, and examples.
Contributing
Contributions to dydantic are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository: https://github.com/hinthornw/dydantic
Before contributing, please read our contributing guidelines for more information on how to get started.
License
dydantic is open-source software licensed under the MIT License.
Acknowledgments
We would like to express our gratitude to the following projects:
- Pydantic - Dydantic builds upon the awesome Pydantic library, which provides the foundation for data validation and serialization.
- JSON Schema - Dydantic leverages the JSON Schema specification to define the structure and constraints of the data models.
- All the contributors who have helped improve dydantic with their valuable feedback, bug reports, and code contributions.
Thank you for using dydantic! If you have any questions or need assistance, please don't hesitate to reach out.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file dydantic-0.0.5.tar.gz
.
File metadata
- Download URL: dydantic-0.0.5.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.2 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e5441fc463277f4380146edfa7b5a7a35bf1f1093ac4d4908f1e75808ca6418 |
|
MD5 | 62156649bc12dd9fa377bd5e3fa3f334 |
|
BLAKE2b-256 | aef02ef18ddc8fda71c1b3c44930a15e0035c837599012eb75ac0695022a4228 |
File details
Details for the file dydantic-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: dydantic-0.0.5-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.2 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad22349b9684363feb4e9531dc7f900ff2ec86ef6e6968ec5bb0d259110fe87c |
|
MD5 | 3406b29fb6b64a57083d005e6a005e51 |
|
BLAKE2b-256 | 5c67238570eeac85f689d72e12216b7bd68d27625f43c5748e06948baa9f5540 |