pypi / datamodel-code-generator
datamodel-code-generator
What changed in datamodel-code-generator 0.60 to 0.96, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
20 breaking14 security3 deprecations11 new APIs and options1 performance13 behavior and defaults1 tooling27 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initdatamodel-code-generator 0.968 changes
Breaking changes 2
For stream responses whose schema is only an itemSchema, generated operation methods and result aliases now return the whole raw body instead of the item model; use the generated stream helper to get typed items.
Generated SSE, JSON Lines and NDJSON stream helpers for a bare $ref itemSchema now use the referenced model rather than a duplicate ItemSchema or ItemSchemaModel.
New APIs and options 2
When enabled, const, enum, nested composition, false schemas and full referenced schemas are considered when identifying branches that admit no object; object keywords are omitted from those branches.
Generated GraphQL models now have a __typename property that graphql-core can read.
Behavior and default changes 2
Notices are now attributed to the outermost calling frame outside the package, so filters matching module="datamodel_code_generator" no longer suppress them.
Users of unmodeled mapped and x-python-import refs are now typed by import, and mapped classes are imported only in modules that use them.
Fixes and other changes 2
The Genson notice is skipped when an installed package declares the extra.
Pydantic v2 output now chooses string literal quoting to avoid adding an unintended backslash before quotes in regex patterns; the published pattern no longer contains the extra backslash.
datamodel-code-generator 0.957 changes
Breaking changes 3
With schema validators enabled, mapped references no longer contribute runtime validation rules; generated models may accept data they previously rejected.
Generated FastAPI endpoint and service Protocol signatures use the plain type for required nullable parameters without content; callers that pass None or rely on the old signatures get type errors.
With untrusted-input checking enabled, generation now errors for schemas nested more than 100 levels or containing more than 2,000,000 objects and arrays.
Deprecations 2
Using a custom template directory now emits a FutureWarning about Jinja2 becoming optional; configurations that treat warnings as errors can fail until the warning is filtered.
Generating from JSON, YAML, or CSV sample data now emits a FutureWarning about Genson becoming optional; schema inputs do not warn.
Behavior and default changes 1
Dynamic model and module generation skip formatting when no formatter is selected; set formatters to restore formatting and stripped docstring whitespace.
Fixes and other changes 1
Object keywords beside anyOf are read for object branches when an option is enabled.
datamodel-code-generator 0.945 changes
Breaking changes 2
Generated client arguments for required nullable query, path, header, and cookie parameters serialized by style no longer accept None; passing None or an optional-typed value now fails type checking.
Strict schema-version mode now checks nested subschemas.
New APIs and options 1
Adds presets named 20261111.
Tooling 1
A datamodel-codegen alias package is published with each release.
Fixes and other changes 1
Fixes float constants with equal bounds when this option is used.
datamodel-code-generator 0.937 changes
Breaking changes 3
The builtin formatter changes generated-code layout, including string wrapping, imports, comments, indentation, and function bodies, to follow black and isort conventions.
The generator can no longer be installed or run on Python 3.10; its minimum runtime is now Python 3.11. Generated code targeting Python 3.10 is unchanged.
Using --validation with --no-allow-remote-refs now raises an error and generates no code, because the validator fetches remote $ref URLs.
Performance 1
The builtin formatter's line layout is faster.
Fixes and other changes 3
The generator warns when Pydantic 2.14 refuses a bytes pattern at import.
Generated client output leaves out request media types the client cannot write, rather than omitting the operation.
Reserved parameter names are written only where additional keys read them.
datamodel-code-generator 0.9224 changes
Security 1
Adds an option to refuse external refs and code keywords in input.
New APIs and options 4
Generates a WebSocket client from AsyncAPI documents, including handshake query, headers and credentials, channels sharing an address, and server-sent event channels.
Writes deepObject query arrays as name[]=value and scalars as name=value; it also supports nested deepObject values and URL-encoded form bodies.
Adds an experimental Python API that returns the root class and the class for each schema location alongside the models.
With register_module=True, dynamic classes are registered so that they and their instances can be pickled.
Behavior and default changes 6
Routes multiple messages per channel direction, sends subclass messages using their nearest class's encoder, and reads string discriminators as the property they name.
The builtin formatter graduates from experimental.
The formatter splits long lines as black does, measures line widths as black does across Python versions, and sorts imported names in natural order.
Includes the empty subclass written for a duplicate by --reuse-model, at the duplicate's location.
The Python API is marked experimental.
Unsupported operations caused only by their own declarations are skipped with one UserWarning naming the operation and reasons; other operations are generated. Generation still fails if all operations are skipped or a document- or setting-level refusal occurs.
Fixes and other changes 13
Fixes client handshake URLs and empty packages.
Includes the empty subclass written for a duplicate by --reuse-model in models_by_source_ref, at the duplicate's location.
Uses the call's parameter value where an API key credential would go when provided, and uses the credential when it is not.
Sends and reads a whole JSON body declared as a binary string as raw octets of its media type.
Generates multipart requests whose body schema is a union of objects by merging their parts by name.
Writes a parameter declared as one item or an array according to its style, treating each item as a scalar.
An unsupported security alternative is left out when an operation declares another alternative the client can use, rather than causing the operation to be skipped.
Sends one credential when schemes in an AND requirement place the same kind at one position, allowing documents that require two OAuth 2 schemes together to generate a client.
Writes patterns for an output regex engine, selecting python-re when the Rust engine refuses a pattern, rewriting an unescaped bracket in a class, and warning when no engine compiles a pattern.
On macOS, watch mode detects directory changes that happen before generation ends and polls only existing dependencies rather than walking the surrounding project tree.
Watch mode starts again while skipping unreadable directories below a watched root, rather than failing to start.
Retries YAML documents that libyaml cannot read using PyYAML's scanner, avoiding differences in document reading based on whether PyYAML has libyaml.
Reads a plain = in YAML input as the string =, as YAML 1.2 does, rather than refusing the document.
datamodel-code-generator 0.8616 changes
Breaking changes 5
Mapped format: byte strings with length constraints now generate Annotated bytes using EncodedBytes and Base64Encoder, decoding base64 and checking lengths on the encoded text.
Mapped format: byte fields under strict bytes now decode base64 instead of holding raw text; FastAPI path, query, header, and cookie parameters no longer stop generation with an error.
Mapped format: byte values without constraints now pass through base64 decoding, including byte strings in multi-type schemas.
Integer and subclass enums listing null no longer generate a None member that raises TypeError on import; an enum containing only null becomes RootModel[None].
Optional one-value Literal discriminator tags now default to their sole value instead of None, allowing the discriminated union to import.
Deprecations 1
The generator warns about msgspec unions containing an Enum alongside another member of the same JSON type.
New APIs and options 3
Adds schema analysis and rule-based recommendations for generation options.
Adds an option to represent single-value enums as constants; nullable unions and mixed-type branches are kept distinct, and nullable single-value enums remain enums that accept null.
Adds an option to use tag values as union variant names; prefixed names of models inside key-named branches no longer repeat the key.
Behavior and default changes 2
Long Annotated assignments with a None default are wrapped like black; --check with a dated preset using the builtin formatter reports the reformatting.
Warns when keys in the model name map match no generated model.
Fixes and other changes 5
Number constraints are no longer emitted on generated fields whose types do not take them.
Pydantic discriminator tag fields no longer carry a pattern that every tag value already satisfies, avoiding generated output that fails at import.
Generated msgspec Structs are flattened when their generated bases have conflicting layouts.
A stale name for a renamed type is released from a package __init__ re-import.
Generated code now imports the object that holds enum members used by x-python-type Literals.
datamodel-code-generator 0.8510 changes
Breaking changes 5
Output encoding failures now raise datamodel_code_generator.Error instead of codec exceptions; modular output writes no files if a module cannot be encoded.
Unknown encodings and codecs that are not text encodings are rejected during config preparation, before input is read or output paths are created.
The builtin formatter now classifies standard-library imports using the target Python version; when no target is given, it uses 3.10.
Non-ASCII generated names now follow the target Python version's Unicode rules, which can change field, class, enum member, and module names.
Generation fails if a referenced standard-library type is unavailable in the target Python version.
New APIs and options 1
Python 3.15 is now available as a target version.
Behavior and default changes 2
The builtin formatter now places each module in a multi-module import statement in its own section according to its category.
Explicit names are validated against the target Python version's identifier rules rather than those of the running interpreter.
Fixes and other changes 2
Model reuse now recognizes references starting with non-ASCII letters, so equivalent models can be reused instead of emitted as duplicates.
Newer typing and collections.abc names requested through overrides or schema import paths are imported from typing_extensions when unavailable in the target Python version.
datamodel-code-generator 0.811 changes
Security 1
datamodel-code-generator: Protobuf weak-import path traversal allows files to be written outside the temporary directory
datamodel-code-generator 0.641 changes
Security 1
datamodel-code-generator vulnerable to code injection via
x-python-import/customTypePathin generated import statements
datamodel-code-generator 0.632 changes
Security 2
datamodel-code-generator: Authorization / request headers leaked to cross-origin redirect target when fetching remote schemas
datamodel-code-generator vulnerable to SSRF protection bypass via DNS rebinding
datamodel-code-generator 0.622 changes
Security 2
datamodel-code-generator vulnerable to arbitrary local file read via JSON-Schema
$ref(file://and../traversal), bypassing--no-allow-remote-refsdatamodel-code-generator vulnerable to arbitrary local file read via XSD
schemaLocation(xs:include/xs:import) path traversal, with no remote-ref gate
datamodel-code-generator 0.612 changes
Security 2
datamodel-code-generator vulnerable to SSRF via JSON-Schema
$refto HTTP URL (silent by default)datamodel-code-generator vulnerable to SSRF via --url: no host/IP validation, follows redirects
datamodel-code-generator 0.605 changes
Security 5
datamodel-code-generatorvulnerable to code execution on import via unescapedvalidatorsentries in --extra-template-datadatamodel-code-generatorvulnerable to code execution on import viax-python-typeJSON-Schema extension in datamodel-code-generatordatamodel-code-generatorvulnerable to code injection in via attacker-controlleddefault_factoryschema fielddatamodel-code-generatorvulnerable to code injection via unescaped carriage return in--extra-template-datacommentfielddatamodel-code-generatorvulnerable to code injection via unescaped carriage return in GraphQL Union description