datamodel-code-generator
datamodel-code-generator copied to clipboard
Pydantic model and dataclasses.dataclass generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.
we generate datamodels from a folder structure "--input-file-type", "openapi", "--input", ".", "--output-model-type", "pydantic_v2.BaseModel", "--target-python-version", "3.12", "--use-field-description", "--output", "models". the output looks like ``` tree models models └── apis ├── composition_basics...
**Is your feature request related to a problem? Please describe.** I want to implement basic schema registry out of generated models, so I need a way to include extra identifying...
**Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] I'm generating model from...
**Describe the bug** When I use `--output-model-type=dataclasses.dataclass`, `datamodel-codegen` generates enums with invalid defaults. The defaults are invalid because they refer to enums defined in the same package by their full...
**Describe the bug** First of all, thank you for the great work on datamodel-code-generator! I have a question regarding how to handle oneOf in OpenAPI schemas, and I'm wondering if...
**Describe the bug** When the `default` value is set in a referenced schema in OpenAPI 3.1 and it has `type: ["string", "null"]`, the default value of dataclass becomes `None` while...
**Describe the bug** generated pydantic code is faulty when the field name matches the generated enum name for a given field. **To Reproduce** Example schema: ```json { "properties": { "a_int":...
**Describe the bug** Importing a schema and partial overwrite it (e.g., set a different default value) leads to lost type information **To Reproduce** schemaA ```json { "type": "object", "title": "SchemaA",...
**Describe the bug** allOf with a single `$ref` with a local json-pointer in schemaA.json is not resolved correctly with schemaA.json is itself referenced from schemaB.json. It seems like schemaB.json (where...
**Describe the bug** Using `const` combined with `minimum` and `maximum` inside `anyOf` in a JSON schema does not yield the desired result when generating a model. **To Reproduce** Example schema:...