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.
**Describe the bug** It should forbid `extra_fields` by default. PyDantic_v2 itself ignores `extra_fields` per default. So I expect `datamodel-code-gen` to explicitly set `allow_extra_fields=False` unless `--allow-extra-fields` is specified **To Reproduce** Example...
I believe the pattern matching described in #470 may no longer be compatible with PyLance. For example, creating a json schema like: ``` properties = { 'session': { 'type': 'string',...
**Describe the bug** `--field-constraints` with pydantic2 is supposed to use `Field(pattern=)` instead of `constr`. This works except when the field is defined as `type:string format:hostname` (and maybe other edge cases?)....
Hey all, first of all thank you all for coming up with this project and the continued work on it. I bumped into the following crash this morning. I may...
updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.7 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.7...v0.6.2)
- Fixes two bugs for pydantic v2 --use-annotated: - incorrect default value for optional lists - incorrect default value "style" for Annotated fields: default value style before the fix: `fieldname:...
When generating a definitions from a schema, if defaults are used for dictionaries or arrays, **datamodel-code-generator** currently creates models using the `default` keyword for fields. In my opinion, this should...
**Describe the bug** When a model is generated with a custom header, importing the resulting model module causes the following error: ``` SyntaxError: from __future__ imports must occur at the...
**Describe the bug** Very similar to #1615 but for msgspec.Struct output format **To Reproduce** Example schema: ```yaml openapi: 3.1.0 info: title: Bug report version: 0.0.1 paths: /api: get: responses: '200':...
I'm generating a pydantic_v2.BaseModel from the envoy config jsonschema found here: https://github.com/jcchavezs/envoy-config-schema/releases/tag/v1.21.0 For some of these schema files, if I pass a directory for output it produces this error: ```...