All Changes by Release¶
Every change a user meets when upgrading, newest first. To upgrade from a release, apply every section above it, or open the page for your release.
Unreleased¶
Generated AsyncAPI clients leave out a channel whose payload format generation does not read (unreleased)¶
A channel is now left out with a message_content_types warning where an AsyncAPI 2 message trait gives a schemaFormat that generation does not read, such as application/schema;version=draft-07, which generation refuses when the message itself gives it, or where a message's contentType is no media type but ends in +json (x+json). Such channels were generated with a JSON codec.
- Affects: experimental features:
cli-option.generate-client - What to change: Write the format as the AsyncAPI specification lists it (
application/schema+json;version=draft-07) and the content type as a media type (application/x+json). - Pull requests and issues: #6927
- Source: the release notes
generate() with a server or client target raises Error for a preset that does not fit (unreleased)¶
With generate_server or generate_client, a preset that does not match target_python_version raises datamodel_code_generator.Error, as a model-only run does, with the same message. It raised datamodel_code_generator.preset.PresetError, which is not an Error. The command line is unchanged.
- Affects: experimental features:
cli-option.generate-server,cli-option.generate-client - What to change: Catch
datamodel_code_generator.Errorwhere the code caughtPresetErroraround a target run. - Pull requests and issues: #6851
- Source: the release notes
Generated AsyncAPI clients read handshake parameters and fixed header values from the models (unreleased)¶
The query and header parameters of a channel's handshake are now the fields of the models generated for its binding's query and headers objects, required where the models require them, and the subprotocols a Sec-WebSocket-Protocol header offers, or the Accept header that makes a channel a server-sent event stream, are the values the header's type admits. A channel is now generated whose query or headers object is written with allOf, or with keywords beside its properties such as $schema, examples, default, minProperties or deprecated, or that names a required property it does not declare; such channels were skipped as websocket_bindings or server_sent_events. Channels at one address whose handshakes write a parameter alike but whose models type it differently, such as a $ref that names a schema of another document through an allOf, are still left out as shared_addresses. A Sec-WebSocket-Protocol header written as a oneOf of consts, also one a referenced schema holds whose models are a root model or alias of a union of Literals (a oneOf of $refs to const schemas), now offers each value, where it offered none (and a required one left the channel out), and an Accept header written so now opens the channel as a server-sent event stream. An AsyncAPI 2 operation whose HTTP binding comes from a trait under components/operationTraits now gives its parameters, where its channel was skipped; an operation's own binding, which no model types, still leaves the channel out, with the message the query schema of its HTTP binding has no model. A parameter written as a $ref now takes the description of the schema it names. Under --force-optional the models require no parameter, so every handshake parameter is now optional; a required header that the client writes itself, on a WebSocket handshake or on the GET that opens a server-sent event stream (such as Host, Upgrade, or a free-form Sec-WebSocket-Protocol, which then offers no subprotocol), no longer leaves the channel out, and two bindings that declare one parameter required and optional now agree, where the channel was skipped.
- Affects: experimental features:
cli-option.generate-client - Pull requests and issues: #6943
- Source: the release notes
Generated AsyncAPI 2 clients follow the models for a default beside a handshake parameter's $ref (unreleased)¶
With --ignore-ref-siblings-by-schema-version, an AsyncAPI 2 handshake query or header parameter whose property writes a default beside its $ref no longer takes that default as its argument default, as the generated models do not; it takes the default the referenced schema gives, or none (token: str = 'abc' becomes token: str | UNSET = UNSET). Without the option the client keeps the sibling default, as the models do.
- Affects: experimental features:
cli-option.generate-client - Pull requests and issues: #6970
- Source: the release notes
Generated AsyncAPI clients code a message as the models type its payload (unreleased)¶
How a message travels now follows the models generated for its payload, as an OpenAPI body of its media type does. A text message (text/plain, text/csv, text/xml, text/html, ...) whose models type a string, such as an enum of strings, type: [string], a nullable string, a const or an allOf of a string schema, or a string with contentEncoding, is now sent and received as str; such channels were skipped as message_content_types. A message of another binary media type (image/png, application/xml, application/x-msgpack, ...), which a frame carries as its raw bytes, is now sent and received as bytes whatever its schema (as str where its models type an enum of strings), where it was skipped unless it was a binary string. A message of a form media type (multipart/form-data, application/x-www-form-urlencoded) is still sent and received as bytes only where its models type its payload as raw bytes (a binary string), and its channel is still skipped otherwise. A JSON message on a WebSocket channel whose payload is a binary string (type: string, format: binary) is now raw bytes in a binary frame instead of the payload's model; on a server-sent event channel its data is still decoded by the model. An application/octet-stream message whose payload is an enum of strings, and a text message whose binary string the models type as str (--type-mappings binary=string), are now str instead of bytes.
- Affects: experimental features:
cli-option.generate-client - Pull requests and issues: #6942
- Source: the release notes
Generated AsyncAPI clients read a payload's schema format and wrapper as the models do (unreleased)¶
A channel is now generated whose message payload names its schemaFormat in another case or with spaces (application/SCHEMA+JSON;version=draft-07, application/schema+json ; version=draft-07), in an OpenAPI format (application/vnd.oai.openapi;version=3.0.0), or in such a spelling through an AsyncAPI 2 message trait; such channels were skipped as message_content_types. A payload written {schema: ...} without a schemaFormat now binds the model generated for its schema: where it was the channel's only message, generation failed (The use has no generated native type), and beside another JSON message the channel was skipped as several_messages (a message's payload declares no type). Avro, Protocol Buffers and XML Schema payloads, also when a trait gives the format, stay left out.
- Affects: experimental features:
cli-option.generate-client - Pull requests and issues: #6927
- Source: the release notes
A union --collapse-root-models writes as list items names the tag field its site writes (unreleased)¶
Under --collapse-root-models, a discriminated union that is a named schema and is used as the items of an array is written into the list with discriminator= by the Python name of the tag property, decided before the union itself is written. Where its variants do not all carry that tag, Pydantic refused the module when it was imported: where the variants name the field otherwise, as a property named like the Enum that types it is renamed (Kind_1, #6874), and where the union itself is written without discriminator= and a variant keeps an untagged field (#6892). Such a list now names the field the union names where the union is written with discriminator=, and else is written without one. A list whose variants carry the tag is unchanged, so output that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass; only with:--collapse-root-models - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6874, #6892
- Source: the release notes
-pets: list[Annotated[Cat | Dog, Field(discriminator='Kind')]] | None = None
+pets: list[Annotated[Cat | Dog, Field(discriminator='Kind_1')]] | None = None
A union has no discriminator= where a nested variant takes an untagged field from the first of two bases (unreleased)¶
A discriminated union that lists a oneOf grouping a variant composed (allOf) of two models that share a parent declaring the tag was written with discriminator= by the tag field the second model declares again. Pydantic gives the class of the variant the field of its first base that has one, here the one the first model inherits from the shared parent, and refused the union when the module was imported where that field is optional (needs field 'kind' to be of type Literal, #6905) or holds a tag another variant holds (Value ... mapped to multiple choices, with --enum-field-as-literal all), also where --collapse-root-models writes that union as the items of a list. Such a union is now written as a plain union, without discriminator=; the variants and their tag fields are unchanged, so only the module that holds the union changes. A module that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6905
- Source: the release notes
-thing: Group | Plane | None = Field(None, discriminator='kind')
+thing: Group | Plane | None = None
A union has no discriminator= where the class of a nested variant has an optional tag field (unreleased)¶
A discriminated union that lists a oneOf grouping a variant wrote that variant's tag as the default of the tag field of the root-most parent that declares it. Where a nearer parent declares the same optional const tag again, the class of the variant has that parent's field, which stays optional, and Pydantic refused the union when the module was imported (needs field 'kind' to be of type Literal, #6875); under --use-enum-values-in-discriminator the same happened where such a variant keeps an optional tag typed by its Enum. Such a union is now written as a plain union, without discriminator=; the variants and their tag fields are unchanged, so only the module that holds the union changes. A module that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6875
- Source: the release notes
-thing: Young | Plane | None = Field(None, discriminator='kind')
+thing: Young | Plane | None = None
A union whose variants were written with one tag value has no discriminator= (unreleased)¶
A Pydantic union whose variants ended up with the same value in their tag fields was written with discriminator=, which Pydantic refuses when the module is imported (Value ... mapped to multiple choices). It happened where a union lists a nested oneOf beside the parent of the variant it groups, which has its parent's tag (#6876), also where --collapse-root-models writes that union as the items of a list, and under --use-enum-values-in-discriminator where the discriminator property is named like the Enum that types it and the variants inherit it, so that every variant takes every member (#6865). The union is now written without discriminator=; the tag fields of the variants are unchanged. For #6865 this means that the module imports: its variants still have the tag field with every member of the Enum, and a parsed tag is the text, not the member. Output that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6865, #6876
- Source: the release notes
A Literal member of an enum named through a collapsed alias imports the enum (unreleased)¶
Under --collapse-root-models-name-strategy parent, a module that named an enum of another module through a collapsed alias wrote the enum without importing it in two places: in an enum member literal (--use-enum-values-in-discriminator, or a const beside an enum under --read-const-beside-enum) and, under --reuse-model, where the enum replaced a duplicate that reuse removed. The models that named it failed when they were used. The module now imports the enum and writes Literal[b.Foo.cat, 'cat']. Output that worked before is unchanged.
- Affects: only with:
--collapse-root-models-name-strategy parent - Keep the old output: The previous module imported, but the models that named the enum failed at first use, as the module did not import it; nothing restores it.
- Pull requests and issues: #6842
- Source: the release notes
A pattern with a class escape or a Unicode property at the end of a range in a class, such as ^[a-\w]+$, no longer fails at import (unreleased)¶
A pattern whose character class ends a range with a class escape or a Unicode property (^[a-\w]+$, [a-\pL], [a-\p{L}]) was written as the schema writes it, and the module failed at import with invalid range boundary, must be a literal (a msgspec.Struct failed when it first decoded the type with bad character range): Pydantic's default regex engine refuses a range that ends with a class, and Python's re rejects it too. The pattern is now left out with a warning, as ^[\w- ]*$ (a class as the start of a range) has been since 0.92.0, and the model checks the other keywords only. A hyphen that makes no range keeps its pattern (^[a-z0-9-\s]+$, ^[^-\w]+$). Output that imported and decoded before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass,msgspec.Struct - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6922
- Source: the release notes
A pattern with a one-letter Unicode property before a hyphen in a class, such as ^[\pL-_]+$, no longer fails at import (unreleased)¶
A pattern whose character class starts a range with a Unicode property of one letter (^[\pL-_]+$, [\PL-_]) was written as the schema writes it, and the module failed at import with invalid range boundary, must be a literal: Pydantic's default regex engine refuses a range that starts with a class, and Python's re rejects \p. The pattern is now left out with a warning, as ^[\p{L}-_]+$ has been since 0.92.0, and the model checks the other keywords only. Output that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6918
- Source: the release notes
More patterns past the regex size limit no longer fail at import, such as ^\p{L}{1,256}$, ^.{0,10240}$ and [\p{L}\p{N}_-]{1,256} (unreleased)¶
A pattern that every pydantic-core release from 2.0 to 2.50 refuses for size, but that the size check counted below the limit, was written as the schema writes it, and the module failed at import with Compiled regex exceeds size limit: a class of several Unicode general categories ([\p{L}\p{N}_-]{1,256}, ^[\p{L}\p{Z}\p{N}_.:/=+\-@]{0,256}$), \p{Lu} or \p{Ll}, a count that passes the limit only with what the ASCII characters of its atom and its optional copies add (^\p{L}{1,256}$, ^.{0,10240}$, ^[^<>]{1,10000}$), a counted group of single atoms (^(?:[\w-]\.?){1,128}@(?:[\w-]\.?){1,128}$) and an alternation without ^ or $ in which every branch holds at least one copy of these classes or escapes outside a group (user-[\w-]{1,128}|group-[\w-]{1,128}). The model now selects regex_engine="python-re" for it; a pattern Python's re rejects too, as it rejects \p{...}, is left out with a warning. Only patterns that every pydantic-core release from 2.0 to 2.50 refuses are read this way. Output that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6908
- Source: the release notes
A pattern past the regex size limit by repetitions together or by a Unicode class no longer fails at import (unreleased)¶
A pattern whose counted repetitions pass the size limit of Pydantic's default regex engine only together (four classes such as [\w+=,.@-]{1,64}), that repeats a class of \w and \d or \s (^[\w\s-]{1,255}$), or that repeats a class of a major Unicode general category ([^\p{C}]{1,2048}, [\P{M}\p{M}]{0,20000}), was written as the schema writes it, and the module failed at import with Compiled regex exceeds size limit. The model now selects regex_engine="python-re" for it; a pattern Python's re rejects too, as it rejects \p{...}, is left out with a warning. That is what a single repetition past the limit has got since 0.92.0. Only patterns that every pydantic-core release from 2.0 to 2.50 refuses are read this way. Output that imported before is unchanged.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Keep the old output: The previous module failed at import; nothing restores it.
- Pull requests and issues: #6877
- Source: the release notes
Generated clients and servers name colliding API names as the models' naming strategies do (unreleased)¶
Two changes, both under --parent-scoped-naming. (1) With --naming-strategy numbered, primary-first or definitions-first, a method, handler or class name that another name in its scope already holds now takes the name of its enclosing scope in front of it instead of a number (get_a_b_1 becomes default_get_a_b, GetAB1 becomes DefaultGetAB). (2) With --naming-strategy full-path, such a name now takes both prefixes, as the models' class names do (row legacy-both-prefixes, #5666): item_store_get_item becomes item_store_item_store_get_item, ItemStoreGetItemResponse becomes ItemStoreItemStoreGetItemResponse.
- Affects: experimental features:
cli-option.generate-client,cli-option.generate-server - Pull requests and issues: #6976
- Source: the release notes
An argument that turns off an option pyproject.toml turned on, whose implied option stays on, emits a UserWarning (unreleased)¶
The command line reads the values of pyproject.toml before it applies the arguments, so with use-annotated = true and field-constraints = false there, --no-use-annotated turns --use-annotated off and leaves --field-constraints on, which use-annotated = true turned on. Such a run now reports it with a UserWarning that names the key and --read-implied-options-from-merged-values; the option stays on as before and the generated output is unchanged. A caller that turns warnings into errors gets an error.
- Affects: only with:
--no-use-annotated - What to change: Set
use-annotated = falseinpyproject.tomlinstead of passing--no-use-annotated, or pass--read-implied-options-from-merged-values(the 20261113 presets turn it on), under which the argument turns--field-constraintsoff as the key does. - Pull requests and issues: #6891
- Source: the release notes
A member of $defs that is not a schema is skipped with a UserWarning in a draft 7 or older document (unreleased)¶
Draft 7 and older have no $defs keyword, so their meta-schemas do not constrain its members. In a document read in one of these versions (the version of the input document, or of each document under --read-schema-version-per-document), a member of $defs whose value is neither an object nor a boolean, such as a description string written beside the definitions, is now skipped with a UserWarning that names it, and the document is generated; it was refused before. Such a member is still refused in a document read as 2019-09 or later (a document without $schema that holds $defs reads as 2020-12) and where a reference names it. A caller that turns warnings into errors gets an error.
- Affects: input types:
jsonschema - What to change: Move the value into the definition it belongs to, or remove it.
- Pull requests and issues: #6880
- Source: the release notes
A $ref to its document's $id written with an empty fragment emits a SchemaResourceRefWarning before the fetch (unreleased)¶
Where a document declares an $id with an empty fragment (https://example.com/item.json#) and a $ref in it names that URI, the generator loads the document at that URL, as before, and now first warns with a SchemaResourceRefWarning that names the URL, the $id and --read-ids-with-empty-fragment, under which the reference resolves inside the document; the generated output is unchanged. A caller that turns warnings into errors gets an error.
- Affects: input types:
jsonschema,openapi - What to change: Pass
--read-ids-with-empty-fragment(the 20261113 presets turn it on), or write the$idwithout the#. - Pull requests and issues: #6878
- Source: the release notes
An option that is turned off and that another option turns on emits a UserWarning (unreleased)¶
--use-annotated turns --field-constraints on, --use-type-alias-type turns --use-type-alias on and --intersect-combined-schema-keywords turns --intersect-allof-keywords on, also where a preset sets the first option. A run that turns the second option off (--no-intersect-allof-keywords, false in pyproject.toml, False given to generate()) is now reported with a UserWarning that names both options and how to turn both off; the option stays on as before and the generated output is unchanged. A false in pyproject.toml is not reported under a --preset argument whose preset sets that option, as such a preset replaces the values of pyproject.toml. generate() does not report use_type_alias, nor a value of a config that load_pyproject_config() returned. A caller that turns warnings into errors gets an error.
- Affects: only with:
--field-constraints,--use-type-alias,--intersect-allof-keywords - What to change: Turn the other option off as the warning says, for example with
--no-intersect-combined-schema-keywords, or drop the value that turns the option off. - Pull requests and issues: #6850
- Source: the release notes
A Swagger 2.0 document is named in the notice of the inferred input type and in the refusal of --input-file-type openapi (unreleased)¶
A document whose root has a swagger key and no openapi key is read as YAML or JSON data when --input-file-type is not given, and the OpenAPI reader finds no model in it, as it reads components/schemas, not the definitions of Swagger 2.0. The notice that names the inferred type now adds a line that the input looks like a Swagger 2.0 document, which is read as data, and that its definitions are read as JSON Schema with --input-file-type jsonschema. The refusal Models not found in the input data of such a document under --input-file-type openapi continues with the cause and what to do. The inferred type, the generated output and every document that generates are unchanged.
- Affects: input types:
yaml,json,openapi - What to change: Read the definitions of the document as JSON Schema with
--input-file-type jsonschema, or convert the document to OpenAPI 3. - Pull requests and issues: #6882
- Source: the release notes
--type-overrides keys that match no model or field emit a UserWarning (unreleased)¶
A key of --type-overrides that names no generated model or field is reported with a UserWarning; the generated output is unchanged. A caller that turns warnings into errors gets an error.
- Affects: only with:
--type-overrides - What to change: Fix or drop the keys the warning names.
- Pull requests and issues: #6835
- Source: the release notes
--field-include-all-keys writes the contains keywords beside a $ref in the order of the schema (unreleased)¶
With --field-include-all-keys, a $ref to an array schema with contains beside it wrote contains, minContains and maxContains into json_schema_extra in an order that depended on the hash seed of the process, so one command gave either of two files and --check failed at random. They are now written in the order the schema writes them. The models behave the same: only the order of the keys of the json_schema_extra dict changes, to one of the two orders earlier runs produced.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass; only with:--field-include-all-keys - Pull requests and issues: #6866
- Source: the release notes
-json_schema_extra={'minContains': 0, 'contains': {'const': 'a'}},
+json_schema_extra={'contains': {'const': 'a'}, 'minContains': 0},
New option --infer-union-discriminators (--no-infer-union-discriminators) (unreleased)¶
Write a oneOf or anyOf that declares no discriminator as a discriminated union (Pydantic Field(discriminator=...), msgspec tagged structs) when every branch that is not null requires one property holding one string or integer value (a const or a one-value enum, also through allOf members and local $refs), with no value shared; in Pydantic output a union with a discriminator keyword keeps it. Valid payloads parse the same, except that a tag typed as a one-value enum class becomes its Literal value; with --use-one-literal-as-default a payload without the tag, which the schema requires, is rejected. An invalid payload reports the errors of the branch its tag names, or one tag error. Not applied to dataclasses.dataclass and typing.TypedDict output. Without it these unions are smart unions in Pydantic output, and msgspec output tags only the unions whose tags are written on the branches themselves, as in 0.96.0
- Source: the command-line options of both releases
New option --open-enum-base-class-map (unreleased)¶
Base classes that open the Enum classes of open enums (--open-enums), by the class the enum is written on (JSON or JSON file path). Keys: Enum, StrEnum, IntEnum. Example: '{"StrEnum": "mypkg.OpenStrEnum", "IntEnum": "mypkg.OpenIntEnum"}'. Each is your member-less subclass of that class whose missing keeps a value it does not list; a value type before Enum (--use-subclass-enum) stays: (str, mypkg.OpenEnum). An open enum whose class has no entry, or that is written as a Literal, is written as Literal[...] joined with its type
- Source: the command-line options of both releases
New option --open-enums (unreleased)¶
Accept values an enum does not list. extensible: the enums whose schema marks them open (x-extensible-enum: true, or x-ms-enum with modelAsString: true); all: every enum of two or more values, except one whose schema closes it (x-extensible-enum: false, modelAsString: false); none: no enum, as without the option. An open enum is written as its Enum class on the base --open-enum-base-class-map names for that class, else as Literal[...] joined with its type (Literal['red', 'green'] | str), whatever the options say about Literals
- Source: the command-line options of both releases
New option --read-format-as-annotation (--no-read-format-as-annotation) (unreleased)¶
Read the format of a schema as an annotation, as JSON Schema does: a string, integer or number schema takes the type its type keyword gives (str, int, float), with its own length, pattern and bound keywords, so every value the schema accepts validates, a string or integer dumps as written (a number as the float it parses to, as without a format), and an unknown format gives no warning; a format that a --type-mappings entry names for the schema's type keeps that mapping, and format: binary stays bytes. Without it each known format selects a type (EmailStr, AwareDatetime, UUID, Decimal, SecretStr, Base64Str, ...), as in 0.96.0
- Source: the command-line options of both releases
New option --read-ids-with-empty-fragment (--no-read-ids-with-empty-fragment) (unreleased)¶
Read an $id that ends with an empty fragment, such as https://example.com/item.json#, as the URI without it, which names the same resource, so a $ref to https://example.com/item.json# or https://example.com/item.json#/definitions/Tag in the document that declares it resolves inside that document; without it such a $ref loads the document at that URL, from the network, as in 0.96.0.
- Source: the command-line options of both releases
New option --read-implied-options-from-merged-values (--no-read-implied-options-from-merged-values) (unreleased)¶
Read the options that another option turns on (--use-annotated turns on --field-constraints) from the arguments and pyproject.toml together, so --no-use-annotated over use-annotated = true in pyproject.toml also leaves --field-constraints off where pyproject.toml gives it false, as use-annotated = false there does; without it --field-constraints stays on, as in 0.96.0.
- Source: the command-line options of both releases
New option --read-inherited-property-schemas-in-mro-order (--no-read-inherited-property-schemas-in-mro-order) (unreleased)¶
With --intersect-combined-schema-keywords, give a property that a model only makes required the schema its allOf parents declare, read in the order of the class bases from the allOf members the model's own fields are read from (an alias member followed to the schema it names, the keywords beside a $ref member read with it), so a model written before its parents takes the field it takes when written after them; without it the declaration is looked up in the allOf members as written, and under --intersect-combined-schema-keywords such a field can lose its description or its constraints or become Any, as in 0.96.0
- Source: the command-line options of both releases
New option --read-kubernetes-extensions (--no-read-kubernetes-extensions) (unreleased)¶
Read the Kubernetes schema extensions as the keywords they stand for: x-kubernetes-int-or-string (and the int-or-string format) as an integer or a string, x-kubernetes-preserve-unknown-fields beside properties as additionalProperties true, and an x-kubernetes-group-version-kind as the const and default of the apiVersion and kind it names; without it they are ignored, as in 0.96.0
- Source: the command-line options of both releases
New option --read-single-allof-refs-in-their-documents (--no-read-single-allof-refs-in-their-documents) (unreleased)¶
Read the target of the one $ref of an allOf as every other $ref is read: in the document that holds the schema, a plain-name anchor such as #code included. The target decides whether the schema is typed as the referenced enum, as a root model over it, or refused, so a schema of a referenced file takes the form the same schemas take in one file; without it the target is read at the same pointer of the input document, where a plain-name anchor names nothing, so such a schema can be written as a copy of the enum or refused, as in 0.96.0.
- Source: the command-line options of both releases
New option --read-yaml-1-1-numbers-as-text (--no-read-yaml-1-1-numbers-as-text) (unreleased)¶
Read an unquoted YAML value with _ or : that YAML 1.1 reads as a number, such as 16:9 (969 in base 60), 18_24 or 1_000, as its text, as YAML 1.2, which OpenAPI names, and the ryaml reader read it, also in enum, default, const, examples, extensions and YAML data input. Without it such a value is the number YAML 1.1 reads, as in 0.96.0, except where a string is required in a document that the number makes invalid (a pattern, a format, a description, a component or property name), where it is its text.
- Source: the command-line options of both releases
New option --untyped-value-type (unreleased)¶
Write each value the schema leaves untyped ({}, true, a schema whose keywords give it no type, the values of an object without properties and the items of an array without items) as this type instead of Any: pydantic.JsonValue (Pydantic 2.5 or later), object, Any or the dotted import path of a type of your own, which the models import; the structure is as without the option. --type-overrides, x-python-type and x-python-import keep their types, and msgspec.Struct output keeps Any, which msgspec decodes into JSON values. Without it untyped values are Any, and object in containers under --use-object-type, as in 0.96.0
- Source: the command-line options of both releases
New option --use-x-python-import-for-every-ref (--no-use-x-python-import-for-every-ref) (unreleased)¶
Type every reference to a schema with x-python-import by the class it imports, as a $ref to it at a field is: also an allOf of it beside keywords that add no field where a JSON pointer into another document or a whole-document $ref names it, and under --read-only-write-only-model-type request-response a model does not split for the readOnly or writeOnly properties of such a schema, nor for those its allOf bases reach through one; without it such a reference keeps the model of its schema and those models split, as in 0.96.0
- Source: the command-line options of both releases
New dated presets standard-py3XX-20261113 and practical-py3XX-20261113 (unreleased)¶
They keep the options of the 20261112 presets and add:
- x-python-import for every reference (
--use-x-python-import-for-every-ref): Type every reference to a schema with x-python-import by the class it imports, also an allOf of one in another document, and split no request/response model for the readOnly or writeOnly properties of such a schema. - Extensible enums accept new values (
--open-enums extensible): Accept the values an API adds to an enum its schema marks extensible (x-extensible-enum: true, x-ms-enum modelAsString: true), written as Literal[...] joined with its type, such as Literal['red', 'green'] | str, instead of rejecting them. - Discriminators inferred from tags (
--infer-union-discriminators): Write a oneOf or anyOf without a discriminator as a discriminated union where every branch that is not null requires one property with one string or integer value, also in its allOf members; valid payloads parse the same, an invalid one reports the errors of the branch its tag names. - Kubernetes extensions read (
--read-kubernetes-extensions): Read x-kubernetes-int-or-string as an integer or a string, x-kubernetes-preserve-unknown-fields beside properties as extra keys kept, and an x-kubernetes-group-version-kind as the one apiVersion and kind a resource takes, so the models accept and keep what Kubernetes does. - Inherited property schemas read in MRO order (
--read-inherited-property-schemas-in-mro-order): Give a property that a model only makes required the schema its allOf parents declare, read in the order of the class bases from the allOf members the model's fields are read from, so a model written before its parents takes the field it takes when written after them. - Ids with an empty fragment read as their documents (
--read-ids-with-empty-fragment): Read an absolute-URL $id written with an empty fragment, such as https://example.com/item.json#, as the URI without it, so a $ref to it resolves inside the document that declares it instead of loading the document at that URL from the network. A relative $id is not matched: a $ref to it reads the file. - YAML 1.1-only numbers read as text (
--read-yaml-1-1-numbers-as-text): Read an unquoted YAML value with _ or : that YAML 1.1 reads as a number, such as 16:9 or 18_24, as its text, as YAML 1.2, which OpenAPI names, and the ryaml reader do, so an enum of aspect ratios keeps the values '16:9' and '4:3' instead of the integers 969 and 243. - Implied options read from the merged values (
--read-implied-options-from-merged-values): Read the options that another option turns on from the arguments and pyproject.toml together, so --no-use-annotated over use-annotated = true in pyproject.toml also leaves --field-constraints off where pyproject.toml gives it false, as use-annotated = false there does. - Single allOf references read in their documents (
--read-single-allof-refs-in-their-documents): Read the target of an allOf of one $ref in the document that holds the schema, a plain-name anchor such as #code included, as every other $ref is read, so a schema of a referenced file is typed as a root model over the referenced enum, as the same schemas in one file are, instead of a copy of the enum; a valid referenced file is no longer refused where the input document holds false at that pointer, and a true target there is a root model that accepts every value. -
Untyped values as JSON values (practical presets) (
--untyped-value-type pydantic.JsonValue): Write each value the schema leaves untyped as pydantic.JsonValue instead of Any, the typed form of the object the practical groups prefer for unconstrained values: a JSON document parses to the same values, and Python values that are no JSON values, such as a datetime or a set, are rejected. -
Source: the registry of deprecations, experimental features and dated presets
0.96.0 (2026-11-13)¶
Generated client methods return the raw body of itemSchema stream responses (0.96.0)¶
For an OpenAPI 3.2 response whose text/event-stream, JSON Lines or NDJSON media has only an itemSchema, the operation method, its with_response view and its result type alias read the whole body raw: str for an event stream and bytes for JSON Lines or NDJSON, where they returned the model of the item schema's array projection.
- Affects: experimental features:
cli-option.generate-client - What to change: Parse the raw body, or use the stream helper regenerated clients get at
client.protocols.<resource>.<method>, which yields typed items. - Pull requests and issues: #6767
- Source: the release notes
A protocols helper whose name collides with a derived stream helper is refused (0.96.0)¶
Generation derives a stream helper named <resource>.<method> for each OpenAPI 3.2 operation that streams an itemSchema. A helper of the protocols helper file whose name contains a derived name, or is contained in one, now fails generation with an E_NAME_COLLISION config diagnostic.
- Affects: experimental features:
cli-option.generate-client - What to change: Rename the declared helper.
- Pull requests and issues: #6767
- Source: the release notes
Generated client stream helpers type items as the model their itemSchema references (0.96.0)¶
SSE, JSON Lines and NDJSON stream helpers whose itemSchema is a bare $ref use the referenced model, for example EventStream[models.LogEntry], instead of the ItemSchema or ItemSchemaModel model generated at the item schema location. With Pydantic v2 output, decoded items are instances of the referenced model.
- Affects: experimental features:
cli-option.generate-client - What to change: Annotate,
isinstance-check or match stream items against the referenced model instead ofmodels.ItemSchemaormodels.ItemSchemaModel. - Pull requests and issues: #6771
- Source: the release notes
Deprecation and migration notices name the code that called datamodel-code-generator (0.96.0)¶
Notices of the deprecation registry are attributed to the outermost frame outside the package (your module that called generate(), or the console script) instead of a module inside it. Filters that match them by module="datamodel_code_generator" no longer suppress them, and a script that calls the API directly may now show DeprecationWarning notices that were hidden.
- Affects: Python API:
warnings filters with module="datamodel_code_generator" - What to change: Filter the notices by category and message, or by your calling module, for example
warnings.filterwarnings("ignore", category=FutureWarning, module="mypackage.models"). - Pull requests and issues: #6793
- Source: the release notes
--read-object-keywords-by-type also reads const, enum and allOf branches as admitting no object (0.96.0)¶
An anyOf or oneOf branch that is a const, an enum, a nested allOf, anyOf or oneOf, a false schema or a $ref to such a schema no longer takes the sibling object keywords, so such a site becomes a union, which adds enum classes and can renumber model names (Owner becomes Owner1). The standard and practical 20261112 presets turn the option on.
- Affects: only with:
--read-object-keywords-by-type - Keep the old output: No option restores the 0.95.0 reading;
--model-name-mapcan pin individual names. - Pull requests and issues: #6777
- Source: the release notes
Patterns holding a quote are written without an escaped quote (0.96.0)¶
constr(pattern=r'^it\'s$') is written constr(pattern=r"^it's$"): Python's re matches the same values, and model_json_schema() publishes the schema's pattern unchanged. Snapshot tests and committed generated code show the new text after regenerating.
- Affects: output model types:
pydantic_v2.BaseModel,pydantic_v2.dataclass - Pull requests and issues: #6789, #6790
- Source: generated output of both releases
0.95.0 (2026-11-12)¶
Genson installation now emits FutureWarning (0.95.0)¶
Genson will become optional. Declare the genson extra for JSON, YAML, CSV and dict input; see --help.
- What to change: Declare the genson extra if you generate from JSON, YAML, CSV or dict data.
- Source: the registry of deprecations, experimental features and dated presets
Jinja2 installation now emits FutureWarning (0.95.0)¶
Jinja2 will become optional. Declare the jinja2 extra for --custom-template-dir; see --help.
- What to change: Declare the jinja2 extra if you use custom templates.
- Source: the registry of deprecations, experimental features and dated presets
argcomplete installation is scheduled to change (0.95.0)¶
argcomplete will become optional. Declare the argcomplete extra for shell completion; see "Dependency migration notices" in the documentation.
- What to change: Declare the argcomplete extra if you use shell completion.
- Source: the registry of deprecations, experimental features and dated presets
New dated presets standard-py3XX-20261112 and practical-py3XX-20261112 (0.95.0)¶
They keep the options of the 20261111 presets and add:
-
Object keywords by type (
--read-object-keywords-by-type): Read the keywords that constrain objects only beside an anyOf or oneOf for the branches that admit objects, so a string, const or enum branch beside patternProperties stays itself. -
Source: the registry of deprecations, experimental features and dated presets
0.94.0 (2026-11-12)¶
New dated presets standard-py3XX-20261111 and practical-py3XX-20261111 (0.94.0)¶
They keep the options of the 20261106 presets and add:
-
Float consts fixed by bounds (
--use-bounds-for-float-const): Type a finite float const, which no Literal holds, as a float whose minimum and maximum both equal it, written as the output writes number bounds, so Pydantic and msgspec reject other numbers instead of accepting any float. -
Source: the registry of deprecations, experimental features and dated presets
0.93.0 (2026-11-11)¶
Running datamodel-code-generator on Python 3.10 is removed (0.93.0)¶
Running datamodel-code-generator on Python 3.10 was removed in 0.93.0; run it on Python 3.11 or newer, for example with uvx datamodel-code-generator (uv fetches a supported Python). --target-python-version 3.10 is unaffected.
- What to change: Run datamodel-code-generator on Python 3.11 or newer.
- Source: the registry of deprecations, experimental features and dated presets
0.92.0 (2026-11-10)¶
--generate-client httpx2 with --input-file-type asyncapi, and --client-asyncapi-perspective is experimental (0.92.0)¶
HTTPX2 client generation from AsyncAPI documents is experimental; the channels it opens and the generated package may change.
- Affects: experimental features:
behavior.asyncapi-client - Source: the registry of deprecations, experimental features and dated presets
--untrusted-input is experimental (0.92.0)¶
The untrusted input switch is experimental; the references and schema keywords it refuses may grow as new ways for a schema to read files or write code are found.
- Affects: experimental features:
cli-option.untrusted-input - Source: the registry of deprecations, experimental features and dated presets
generate_dynamic_module(), DynamicModule, and register_module=True is experimental (0.92.0)¶
Dynamic module generation is experimental; its parameters, the DynamicModule attributes, the schema locations it keys classes by, and the module registration rules may change.
- Affects: experimental features:
python-api.generate-dynamic-module - Source: the registry of deprecations, experimental features and dated presets
0.91.0 (2026-11-07)¶
New dated presets standard-py3XX-20261106 and practical-py3XX-20261106 (0.91.0)¶
They keep the options of the 20261104 presets and add:
- Dataclass arguments set to false written (
--keep-false-dataclass-arguments): Write every dataclass decorator argument set to false, such as eq=False from --dataclass-arguments, instead of leaving it out, which gives it its default. - Content parameters typed by their reference (
--keep-content-parameter-refs): Type an OpenAPI parameter whose content media schema is a $ref by the model the $ref names, as a schema parameter is, instead of a copy of the referenced schema. - Extension keys of paths skipped (
--skip-path-extension-keys): In the paths scope, skip a key of paths that begins with x-, a specification extension and no path item, as the api scope does, so its operations get no models. - Every reached input model type reused (
--reuse-every-reached-input-model-type): With --input-model-ref-strategy reuse-all or reuse-foreign, reach the types to reuse through the fields of every model kind, dataclasses too, and import a type the Python type of a field already imports instead of writing an unused copy of it. - x-python-type as written (
--use-x-python-type-as-written): Write a field's x-python-type as given: a union spelled Optional[...] or Union[...] types the field as one spelled X | Y already does, instead of the schema's type, and a container class compatible with the schema, such as tuple or MutableSequence, is written around the schema's item types instead of list, Sequence, set, frozenset or Mapping. - Typed nullable map values (
--use-typed-nullable-map-values): Type the values of a map whose type array lists object alone or with null, such as [object, null], as its additionalProperties say instead of Any, and with --use-typed-map-values-beside-other-types of the 20261027 presets also those of a type array that lists object beside other types. - Unknown fields forbidden by closed msgspec Structs (
--use-msgspec-forbid-unknown-fields): Write forbid_unknown_fields=True on a msgspec Struct whose schema admits no property but its own (additionalProperties: false without patternProperties), so msgspec rejects the unknown fields the schema rejects. - Reference null kept on collapsed root models (
--keep-reference-null-on-collapsed-root-models): Under --collapse-root-models, keep the null of a root model that admits null where a field, item or map value that names it takes its type. - allOf parents read in MRO order (
--read-allof-parents-in-mro-order): Read the allOf parents of every inherited schema in the order of the class bases, so a property that several bases declare takes the nearer base's constraints and description, as the class does. - Field options on every field (
--apply-field-options-to-every-field): Give a GraphQL field, a property whose schema is true or false, a required name without a property and the tag field a discriminator appends the field options the other fields take, such as --use-default-kwarg, --use-annotated and --use-default-factory-for-optional-nested-models. - Strict base64 strings (
--use-strict-str-for-base64): Under --strict-types str, write a format: byte string as the StrictStr that EncodedStr decodes, so Pydantic 2.10 or later refuses bytes for it as for any other strict string, instead of Base64Str. - Content media type strings as bytes (
--use-bytes-for-content-media-type): Type a string of an OpenAPI document that has a contentMediaType and no contentEncoding, raw binary content, as bytes, as a format: binary string is, instead of str. - Constrained string root models collapsed as Annotated (
--collapse-constrained-root-models-as-annotated): Under --collapse-root-models with --use-annotated, inline a root model of a string with constraints into a union, list, dict or other container of its holder as Annotated[str, ...], which keeps the constraints on that member. - Unused models removed beside type overrides (
--remove-unused-models-beside-type-overrides): Remove the models nothing uses, such as an inlined root model, also from a module that a model-level --type-overrides key takes a model out of. - Items of self-referencing arrays kept (
--keep-self-referencing-array-items): Keep the items of an array whose items name the array itself (list[Node | Leaf] instead of list), except in msgspec output, which cannot decode such a type alias. - Shared members kept on collapsed root models (
--keep-shared-members-on-collapsed-root-models): Under --collapse-root-models, keep each member of a root type that collapse inlined at several sites at every site when a root model that member names is collapsed later, as a recursive union reaches its plain member. - Operation enums written as Literal like definitions (
--use-enum-field-as-literal-in-operations): Write the enum of an OpenAPI request body or response as a root model of a Literal where x-enum-field-as-literal, --enum-field-as-literal-map or --enum-field-as-literal writes a definition's enum so, instead of an Enum class. - Request and response variants of numbered models deduplicated (
--dedupe-numbered-request-response-variants): Under --read-only-write-only-model-type, merge a Request or Response variant of a numbered model, such as Page1Request of an inline copy Page1 of Page, into PageRequest where it renders the same, as the numbered model merges into Page. - Defaults of inherited required fields kept (
--keep-defaults-of-inherited-required-fields): With --use-default, keep the default a schema gives a property that only a schema it inherits from lists as required, as --use-default keeps that of a property the schema lists as required itself. - Incomplete model defaults omitted (
--omit-incomplete-model-defaults): Write a property whose object default lacks required fields of its model, such as default: {}, without that default, so input that leaves the property out is valid instead of failing on the default. -
AsyncAPI message trait headers merged (
--merge-message-trait-headers): Give an AsyncAPI message the headers of all its traits, merged in order as JSON Merge Patches, inline and referenced traits alike, and then its own headers, which win. -
Source: the registry of deprecations, experimental features and dated presets
0.90.0 (2026-11-06)¶
New dated presets standard-py3XX-20261104 and practical-py3XX-20261104 (0.90.0)¶
They keep the options of the 20261027 presets and add:
- Shared variant tags merged (
--merge-shared-variant-tags): Give a variant that discriminated unions tag differently, such as one by a mapping key and one by the schema name, every tag they give it, so each union decodes the documents it selects the variant by. msgspec Structs take one tag, so they are unchanged. - EncodedStr for constrained base64 strings (
--use-encoded-str-for-constrained-base64): Write a format: byte string with a pattern or lengths in the field forms as an EncodedStr with the constraints in front of the decoding, so Pydantic 2.10 or later checks them on the base64 text. - Length keywords read by type (
--read-length-keywords-by-type): Read minLength, maxLength and pattern for strings only and minItems, maxItems and uniqueItems for arrays only, so a maxLength beside an array no longer limits how many items the list holds. - msgspec union bounds read exactly (
--read-msgspec-union-bounds-exactly): Decide whether the int member of a msgspec union with a number member drops its bounds on the bounds the schema writes, so a bound past 2**53 no longer rejects an integer the number member accepts. - Model names taken from the schema (
--naming-strategy definitions-first,--name-allof-union-members-after-branches,--use-duplicate-name-suffix-for-every-collision,--capitalize-numbered-enum-members,--keep-first-character-of-path-keys,--name-converted-payloads-by-message,--singularize-last-word-of-item-names): Give every definition its own name before an inline model that asks for it first, name the union members of an allOf after their branches, give the --duplicate-name-suffix suffix to every model renamed because its name is taken, capitalize the number of a capitalized enum member, strip only a leading slash from a paths key, name a converted AsyncAPI payload that names no type after its message, and singularize only the last word of an item model's name. - Schema version read per document (
--read-schema-version-per-document): Read each document by the schema version it declares, or the version of the document that references it, so the keywords beside a $ref and the version's features apply as that version says in every document of a run, and an OpenAPI 3.1 or later document reads them as JSON Schema 2020-12 does. - Ignored $ref siblings left out (
--ignore-ref-siblings-by-schema-version): Read a $ref as its target alone where the schema version ignores the keywords beside it (JSON Schema draft 4, 6 and 7, OpenAPI 3.0, AsyncAPI 2), so a sibling format: binary or uniqueItems no longer changes the type of a field. - Combined schema keywords intersected (
--intersect-combined-schema-keywords): Combine the keywords beside an anyOf or oneOf with each branch, merge an inherited override's nested properties name by name and by its narrowed type, read the $ref siblings, $ref aliases and null branches of allOf members and the required names an allOf adds to the one model it names, and keep no enum value that the merged type rejects, as JSON Schema validates them. - allOf distributed over unions (
--distribute-allof-over-unions): Give an allOf one union variant per combination of the branches of the anyOf and oneOf it holds, also through a $ref member and for their value branches, read a $ref branch with the allOf members and the value keywords beside it, and an OpenAPI body with an allOf beside an anyOf or oneOf as that union, as JSON Schema validates them. - Reference null kept on merged models (
--keep-reference-null-on-merged-models): Keep the null that the schema of a reference admits when its model is merged into an equal model that rejects null, so atype: [object, null]property keeps| Noneafter duplicate removal or reuse. - Meta for msgspec map keys (
--use-msgspec-meta-for-map-keys): Write the keys of a msgspec map whose keys propertyNames or patternProperties constrain as Annotated[str, Meta(...)], so msgspec checks them. - Submodules hidden by classes renamed (
--rename-submodules-hidden-by-classes): Rename a submodule named like a class of its package, such as pkg/Warn.py beside the class Warn of pkg/init.py, to the first free name with trailing underscores, so importing it leaves the class in place. - Unique items as sets by value (
--use-unique-items-as-set-by-value): Under --use-unique-items-as-set, decide each set on the final item types and write one only where every value of its items hashes by value, and keep apart models whose arrays differ in uniqueItems. - Constrained root models kept in every container (
--keep-constrained-root-models-in-every-container): Under --collapse-root-models with --field-constraints, keep a constrained root model named inside any container of its holder, so a set, Sequence or Mapping keeps the constraints of its items. - Enum literal aliases kept (
--keep-enum-literal-aliases): Under --collapse-root-models, keep a named enum that the output writes as a Literal type alias named at its uses. - Plain aliases of recursive models (
--use-plain-alias-for-recursive-models): In Pydantic output, write a type alias whose whole value is a model that names itself as a plain TypeAlias, which every model that uses it builds. - Whole types replaced by type overrides (
--type-overrides-replace-whole-type): Make a class path of --type-overrides replace an object map itself (dict, not dict[str, dict]), and keep the item or property counts of the array or map an override replaces only where the new type counts the same. - SerializeAsAny for every subclass (
--use-serialize-as-any-for-every-subclass): Under --use-serialize-as-any, wrap a field in SerializeAsAny when any subclass of its model in the output adds fields, at any depth, after reuse merges the model and through its module. - Dynamic anchors read in document order (
--read-dynamic-anchors-in-document-order): Resolve a plain-name $dynamicRef that its dynamic scope does not bind, and a reference to a plain name several schemas declare, to the first declaration in document order, so the answer no longer depends on the order the schemas are parsed in. - One model per reference site (
--use-one-model-per-ref-site): Give an object $ref with sibling keywords one model per place it is written, which every unchanged copy of that place shares, so a chain of N definitions gives N-1 site models instead of N(N-1)/2, parsed without nesting. - Escaped reference pointers read (
--read-escaped-ref-pointers): Read the ~0 and ~1 escapes and the percent-encoded octets of a $ref JSON pointer as the characters they encode, so every spelling of a pointer names the one model of its target instead of a copy named after the escaped text. - Pydantic dataclass fields read by alias (
--read-input-model-dataclass-fields-by-alias): With --input-model, read the fields of a Pydantic dataclass by their aliases, as those of a model, so a field with an alias keeps its Python type, such as deque[int], like one without. -
Practical model structure and names (practical presets) (
--reuse-model,--collapse-reuse-models,--use-title-as-name): Deduplicate identical models without empty inheritance wrappers and prefer schema titles for class names; the standard groups keep definitions ahead of inline duplicate names. -
Source: the registry of deprecations, experimental features and dated presets
0.87.0 (2026-10-28)¶
Output changes in 0.87.0 compares the generated models.
New dated presets standard-py3XX-20261027 and practical-py3XX-20261027 (0.87.0)¶
They keep the options of the 20261017 presets and add:
- Enums read as their const (
--use-single-value-enum-as-const): Read an enum of one value, and an enum that admits the const beside it, as that const, so it renders as a Literal value instead of an enum class; one-value enum branches of a oneOf or anyOf merge into one enum. - OpenAPI schemas modeled as definitions (
--openapi-as-definitions paths-bodies ref-components): Give the request and response bodies of the OpenAPI paths and webhooks scopes the model a schema definition of the same body gets, so an object body with a type array such as [object, null] is a model instead of an inline type, and give an OpenAPI component written as a $ref to a recursive schema with sibling keywords the root model a definitions entry of the same schema gets, instead of no model. - Site models for constrained references (
--use-site-models-for-constrained-refs): Give an allOf of $ref members whose other parts add constraints, an enum or a type its own model of the values all parts admit, instead of the referenced type, which leaves the added assertions out; an allOf of enum references gets the enum of the members they share. - Redundant constraints omitted (
--omit-redundant-constraints): Do not write a constraint again beside a type that already enforces it: the bound of a zero-bound class such as NonNegativeInt, and the length and number constraints a const or enum Literal meets by its values, which also keeps such a const branch inline instead of a root model. - Const read beside an enum (
--read-const-beside-enum): Read a const beside an enum as JSON Schema does: a value is typed by the const that narrows the enum, and an enum that admits its const is read as that const. - Literal values filtered (
--filter-literal-values): Keep only the values of a const or enum that meet the length, pattern, bound and multipleOf constraints beside them. - allOf keywords intersected (
--intersect-allof-keywords): Combine the keywords of every part of an allOf, a $ref with sibling keywords and an inherited property override as JSON Schema validates them: the tightest bounds and the values every part admits. - Nullable beside a type list (
--read-nullable-beside-type-list): Write the null that nullable: true declares beside a type list with an object into the root model of that schema under strict nullable output. - Field defaults kept off branch roots (
--keep-field-defaults-off-branch-roots): Leave the default of a property off the root models extracted from the branches of its anyOf or oneOf. - Tuples for closed arrays (
--use-tuple-for-closed-arrays): Generate tuple types for positional arrays that no other item can follow, so that each position keeps its own type. - One dict for object maps (
--use-single-dict-for-object-maps): Type an object map whose keys patternProperties or propertyNames constrain as one dict of the values of every key class. - Stricter pattern-map checks (
--check-pattern-maps-strictly): Under --generate-schema-validators, count every key that a pattern admits, check declared keys against the patterns that match them, and keep the propertyNames keys and the other types of a type array of an object without properties. - Typed map values beside other types (
--use-typed-map-values-beside-other-types): Under --use-typed-nullable-map-values, also type the map values of a type array that lists object beside other types, such as [object, string]. - Enum member values kept (
--keep-enum-member-values): Write an enum as a plain Enum where its IntEnum, StrEnum or (T, Enum) base would change a member value, such as 2.5 beside integer members. - Unevaluated properties read (
--read-unevaluated-properties): Read a schema-valued unevaluatedProperties as additionalProperties where no applicator evaluates the object in place. - Aliases pinned beside an alias generator (
--pin-aliases-with-alias-generator): Write the generated alias on every field of a pydantic dataclass whose config names an alias generator, for pydantic versions older than 2.8. - msgspec tags by payload name (
--tag-msgspec-by-payload-name): Tag the structs of a discriminated union with the property name the document carries instead of the Python name it resolves to. - Constructor fields ordered by final names and written defaults (
--order-constructor-fields-by final-names written-defaults): Order the constructor fields of dataclass and msgspec models after every field has its final name, and the fields of msgspec and Pydantic dataclass models by the defaults they write. - Request and response variants deduplicated (
--dedupe-request-response-variants): Decide Request and Response variants from the schema graph and build each inline model once. - Redundant reference null omitted (
--omit-redundant-reference-null): Do not write None again where a field references a model that holds null itself. - Decimal in field forms (
--use-decimal-in-field-forms): Under --use-decimal-for-multiple-of, write Decimal for a number with multipleOf in the field forms too, and make it strict under --strict-types float. -
Shared parent wrappers collapsed (
--collapse-shared-parent-wrappers): Under the parent name strategy, collapse a wrapper in every model that references it instead of keeping it for the models after the first. -
Source: the registry of deprecations, experimental features and dated presets
0.86.0 (2026-10-18)¶
NamingHintWarning is experimental (0.86.0)¶
The hint at --recommend-options that a command line generation shows when many class names are numbered collisions is experimental; when it is shown and its text may change.
- Affects: experimental features:
behavior.naming-hint - Source: the registry of deprecations, experimental features and dated presets
--recommend-options, its rule data, its candidate comparison, its JSON payload, and --generate-prompt --recommend-options with the prompt JSON field recommendation is experimental (0.86.0)¶
Option recommendations are experimental; the rules, the schema signals they read, the class-name metrics, the report, and the JSON payload may change.
- Affects: experimental features:
cli-option.recommend-options - Source: the registry of deprecations, experimental features and dated presets
New dated presets standard-py3XX-20261017 and practical-py3XX-20261017 (0.86.0)¶
They keep the options of the 20261015 presets and add:
- stdlib dataclass output (
--use-standard-primitive-types,--enum-field-as-literal all): Use stdlib primitive types without renaming input keys because dataclasses do not carry aliases. Stdlib dataclasses keep raw JSON values without conversion, so enums render as Literal values instead of enum classes; this overrides--enum-field-as-literal onefrom All output model types. -
TypedDict output (
--use-standard-primitive-types,--use-frozen-field,--enum-field-as-literal all): Use stdlib primitive types and ReadOnly metadata without renaming dictionary keys. TypedDict holds raw JSON values, so enums render as Literal values instead of enum classes; this overrides--enum-field-as-literal onefrom All output model types. -
Source: the registry of deprecations, experimental features and dated presets
0.85.0 (2026-10-16)¶
New dated presets standard-py3XX-20261015 and practical-py3XX-20261015 (0.85.0)¶
They keep the options of the 20260909 presets and add:
-
Python 3.15 targets
-
Source: the registry of deprecations, experimental features and dated presets
0.84.0 (2026-10-15)¶
Running datamodel-code-generator on Python 3.10 now emits FutureWarning (0.84.0)¶
Running datamodel-code-generator on Python 3.10 was removed in 0.93.0; run it on Python 3.11 or newer, for example with uvx datamodel-code-generator (uv fetches a supported Python). --target-python-version 3.10 is unaffected.
- What to change: Run datamodel-code-generator on Python 3.11 or newer.
- Source: the registry of deprecations, experimental features and dated presets
--generate-client httpx2 and the --client-* options (and their [tool.datamodel-codegen] keys and generate() options) is experimental (0.84.0)¶
HTTPX2 client generation from the CLI is experimental; its options and generated package may change.
- Affects: experimental features:
cli-option.generate-client - Source: the registry of deprecations, experimental features and dated presets
--generate-server fastapi and the --server-* options (and their [tool.datamodel-codegen] keys and generate() options) is experimental (0.84.0)¶
FastAPI server generation from the CLI is experimental; its options and generated package may change.
- Affects: experimental features:
cli-option.generate-server - Source: the registry of deprecations, experimental features and dated presets
0.78.0 (2026-09-09)¶
Black <24.3.0 now emits FutureWarning (0.78.0)¶
Support for Black <24.3.0 will end in a future release.
- What to change: Upgrade Black to >=24.3.0 before the later support change.
- Source: the registry of deprecations, experimental features and dated presets
Black/isort installation now emits FutureWarning (0.78.0)¶
Black/isort will become optional. Declare the corresponding extras; see --help.
- What to change: Declare the black/isort extras for the external formatters you select.
- Source: the registry of deprecations, experimental features and dated presets
isort <6 now emits FutureWarning (0.78.0)¶
Support for isort <6 will end in a future release.
- What to change: Upgrade isort to >=6,<9 before the later support change.
- Source: the registry of deprecations, experimental features and dated presets
DCG runtime Pydantic <2.8.2 now emits FutureWarning (0.78.0)¶
Support for DCG runtime Pydantic <2.8.2 will end in a future release.
- What to change: Upgrade DCG runtime Pydantic to >=2.8.2; generated-code targets are unchanged.
- Source: the registry of deprecations, experimental features and dated presets
New dated presets standard-py3XX-20260909 and practical-py3XX-20260909 (0.78.0)¶
They keep the options of the 20260826 presets and add:
-
Built-in formatting (
--formatters builtin): Format generated models without running an external formatter. For projects using Ruff, override with --formatters ruff-check ruff-format. To preserve Black/isort formatting, override with --formatters black isort. -
Source: the registry of deprecations, experimental features and dated presets
0.76.0 (2026-08-29)¶
--set-default-enum-member is scheduled to change (0.76.0)¶
--set-default-enum-member is deprecated. Use --deserialize-default-values enum instead.
- Affects: only with:
--set-default-enum-member - What to change: --deserialize-default-values enum
- Source: the registry of deprecations, experimental features and dated presets
--install-skill, --skill-scope, and --overwrite-skill is experimental (0.76.0)¶
Bundled Agent Skill installation is experimental; supported clients, scopes, and installed skill contents may change.
- Affects: experimental features:
cli-option.install-skill - Source: the registry of deprecations, experimental features and dated presets
New dated presets standard-py3XX-20260826 and practical-py3XX-20260826 (0.76.0)¶
They keep the options of the 20260619 presets and add:
- All output model types (
--use-standard-collections,--use-union-operator,--use-annotated,--enum-field-as-literal one,--use-subclass-enum,--collapse-root-models,--strict-nullable,--disable-timestamp): Use built-in collection syntax, PEP 604 unions, Annotated constraints, single-value enum Literals, typed enum subclasses, inline root wrappers, schema-accurate nullability, and reproducible file headers. -
Serialized defaults (
--deserialize-default-values decimal enum): Deserialize compatible serialized Decimal and enum defaults into generated Python values while preserving defaults that cannot be converted safely. -
Source: the registry of deprecations, experimental features and dated presets
0.72.3 (2026-08-10)¶
[tool.datamodel-codegen.jobs], --job, --all-jobs is experimental (0.72.3)¶
Named batch jobs are experimental; their configuration schema, batch output, and transactional/watch execution contracts may change.
- Affects: experimental features:
behavior.batch-generation-jobs - Source: the registry of deprecations, experimental features and dated presets
datamodel-codegen.lock, --lockfile, --update-lock, and --locked is experimental (0.72.3)¶
Remote reference integrity locking is experimental: the lock document schema and request-identity compatibility may evolve, but integrity mismatches remain fail-closed and credentials are never persisted.
- Affects: experimental features:
behavior.remote-reference-lock - Source: the registry of deprecations, experimental features and dated presets
0.72.1 (2026-08-04)¶
--use-type-alias-type is experimental (0.72.1)¶
Runtime TypeAliasType output is experimental and may change as Python typing support evolves.
- Affects: experimental features:
cli-option.use-type-alias-type - Source: the registry of deprecations, experimental features and dated presets
0.72.0 (2026-08-03)¶
datamodel-code-generator[httpx2] is experimental (0.72.0)¶
The HTTPX2-backed HTTP client is experimental and may change as compatibility is validated.
- Affects: experimental features:
extra.httpx2 - Source: the registry of deprecations, experimental features and dated presets
0.66.1 (2026-06-30)¶
--generate-schema-validators is experimental (0.66.1)¶
Schema-derived runtime validators are experimental and may change as JSON Schema coverage is expanded.
- Affects: experimental features:
cli-option.generate-schema-validators - Source: the registry of deprecations, experimental features and dated presets
--schema-validator-type is experimental (0.66.1)¶
Schema-derived runtime validator backend selection is experimental and may change as validation backends are added.
- Affects: experimental features:
cli-option.schema-validator-type - Source: the registry of deprecations, experimental features and dated presets
--use-missing-sentinel is experimental (0.66.1)¶
Pydantic MISSING sentinel output is experimental because it depends on pydantic.experimental.missing_sentinel, or on pydantic.MISSING for a 2.14 target.
- Affects: experimental features:
cli-option.use-missing-sentinel - Source: the registry of deprecations, experimental features and dated presets
0.65.0 (2026-06-21)¶
JSON configuration values accepted by legacy validation now emits FutureWarning (0.65.0)¶
JSON configuration values that do not match the documented schema are deprecated and will become validation errors in a future release.
- What to change: Update the JSON configuration to match --output-format-json-schema config.
- Source: the registry of deprecations, experimental features and dated presets
0.64.1 (2026-06-19)¶
New dated presets standard-py3XX-20260619 and practical-py3XX-20260619 (0.64.1)¶
The first dated presets; the presets page lists their options.
- Source: the registry of deprecations, experimental features and dated presets
0.60.0 (2026-06-04)¶
--input-file-type mcp-tools is experimental (0.60.0)¶
MCP tool schema profile input support is experimental and may change as MCP schemas evolve.
- Affects: experimental features:
input-format.mcp-tools - Source: the registry of deprecations, experimental features and dated presets
0.59.0 (2026-05-29)¶
--input-file-type asyncapi is experimental (0.59.0)¶
AsyncAPI input support is experimental and may change as real-world usage is validated.
- Affects: experimental features:
input-format.asyncapi - Source: the registry of deprecations, experimental features and dated presets
--input-file-type avro is experimental (0.59.0)¶
Apache Avro schema input support is experimental and may change as real-world usage is validated.
- Affects: experimental features:
input-format.avro - Source: the registry of deprecations, experimental features and dated presets
--input-file-type protobuf is experimental (0.59.0)¶
Protocol Buffers input support is experimental and may change as real-world usage is validated.
- Affects: experimental features:
input-format.protobuf - Source: the registry of deprecations, experimental features and dated presets
--input-file-type xmlschema is experimental (0.59.0)¶
XML Schema input support is experimental and may change as real-world usage is validated.
- Affects: experimental features:
input-format.xmlschema - Source: the registry of deprecations, experimental features and dated presets
0.56.0 (2026-04-04)¶
Remote $ref fetching without --allow-remote-refs now emits FutureWarning (0.56.0)¶
Remote $ref fetching without --allow-remote-refs is deprecated.
- What to change: Pass --allow-remote-refs for trusted remote schemas, or --no-allow-remote-refs to block HTTP(S) $ref fetching.
- Source: the registry of deprecations, experimental features and dated presets
0.53.0 (2026-01-12)¶
JSON Schema Draft 2020-12 items array tuple validation now emits UserWarning (0.53.0)¶
items as array tuple validation is deprecated in Draft 2020-12. Use prefixItems instead.
- What to change: Use prefixItems.
- Source: the registry of deprecations, experimental features and dated presets
OpenAPI 3.1 nullable keyword now emits DeprecationWarning (0.53.0)¶
nullable keyword is deprecated in OpenAPI 3.1, use type: ["string", "null"] instead.
- What to change: Use type arrays such as type: ["string", "null"].
- Source: the registry of deprecations, experimental features and dated presets
0.52.1 (2026-01-03)¶
Pydantic v2 default for --use-annotated now emits DeprecationWarning (0.52.1)¶
Pydantic v2 with --use-annotated is recommended for correct type annotations. In a future version, --use-annotated will be enabled by default for Pydantic v2.
- What to change: Explicitly pass --use-annotated or --no-use-annotated.
- Source: the registry of deprecations, experimental features and dated presets
PythonVersion.has_type_alias now emits DeprecationWarning (0.52.1)¶
has_type_alias is deprecated and will be removed in a future version.
- Affects: Python API:
PythonVersion.has_type_alias - Source: the registry of deprecations, experimental features and dated presets
0.52.0 (2026-01-02)¶
Default formatters now emits FutureWarning (0.52.0)¶
Default formatters will change to builtin no earlier than three months after 0.92.0. Set --formatters or --preset explicitly; see "Dependency migration notices" in the documentation. Run datamodel-codegen with --recommend-options on one schema to pick a preset and options for it (experimental).
- What to change: Set formatters explicitly, for example black and isort or builtin.
- Source: the registry of deprecations, experimental features and dated presets
0.48.0 (2025-12-24)¶
--parent-scoped-naming now emits DeprecationWarning (0.48.0)¶
--parent-scoped-naming is deprecated. Use --naming-strategy parent-prefixed instead.
- Affects: only with:
--parent-scoped-naming - What to change: --naming-strategy parent-prefixed
- Source: the registry of deprecations, experimental features and dated presets
YAML bool values True, False, TRUE, FALSE now emits DeprecationWarning (0.48.0)¶
Non-lowercase YAML bool values are deprecated. Use lowercase true or false instead.
- What to change: Use lowercase true or false.
- Source: the registry of deprecations, experimental features and dated presets
0.36.0 (2025-11-26)¶
--use-type-alias is experimental (0.36.0)¶
Type alias output is experimental and may change as Python typing support evolves.
- Affects: experimental features:
cli-option.use-type-alias - Source: the registry of deprecations, experimental features and dated presets
0.31.0 (2025-06-12)¶
--allow-extra-fields now emits DeprecationWarning (0.31.0)¶
--allow-extra-fields is deprecated. Use --extra-fields=allow instead.
- Affects: only with:
--allow-extra-fields - What to change: --extra-fields=allow
- Source: the registry of deprecations, experimental features and dated presets
0.24.0 (2023-11-16)¶
--validation now emits DeprecationWarning (0.24.0)¶
The --validation option is deprecated and will be removed in a future release. Use --field-constraints instead.
- Affects: only with:
--validation - What to change: --field-constraints
- Source: the registry of deprecations, experimental features and dated presets