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.
**Is your feature request related to a problem? Please describe.** given a schema like ```yaml components: schemas: HereBeDragons: type: string pattern: here PassMe: type: object properties: mangled_string: anyOf: - $ref:...
**Is your feature request related to a problem? Please describe.** Add support to choose between `AwareDateTime`, `NaiveDateTime` or generic `datetime`. **Describe the solution you'd like** A CLI option to choose...
**Describe the bug** I try to generate models from the OpenAPI JSON spec, but only 2 models are being generated (there are much more in the spec). Generated file: ```python...
**Describe the bug** When a `Literal` field is generated from `discriminator.mapping` in an OpenAPI spec (to Pydantic v2), a default value is not generated even with `--use-one-literal-as-default` flag. **To Reproduce**...
**Describe the bug** int `Parser.parse` function the `self.__apply_discriminator_type(model, imports)` function gets called `for module, models in module_models`, before `module, models, init, imports, scoped_model_resolver` get added to the `processed_models` array. If...
**Describe the bug** When generating pydantic with jsonData, an error occurred: "Invalid file format" **To Reproduce** **Example schema:** - json file:[douyin.json](https://github.com/user-attachments/files/15572393/douyin.json) **Used commandline:** ``` $ datamodel-codegen --input douyin.json --input-file-type json...
Schemas with the same name in the path do not create valid models This specifically happens when both: - The openapi-scopes includes "paths"; and - The schema path has a...
**Is your feature request related to a problem? Please describe.** With pydantic V2, [union modes](https://docs.pydantic.dev/latest/concepts/unions/#union-modes) behave different by default from pydantic V1. We have issues with the default setup and...
**Is your feature request related to a problem? Please describe.** Because Pydantic2 broke... everything, my org still uses Pydantic 1 until everything can be refactored. Because Pydantic 2 had all...
**Describe the bug** `datamodel-codegen` crashed with an error instead of generating code: ``` % poetry run datamodel-codegen --input openapi.yml --input-file-type openapi --output models.py Traceback (most recent call last): File "/Users/user/Library/Caches/pypoetry/virtualenvs/spreadsheet-offset-tool-L93AmRO5-py3.12/lib/python3.12/site-packages/datamodel_code_generator/__main__.py",...