Upgrading from 0.78.0 through 0.83.0 to 0.96.0¶
For datamodel-code-generator 0.78.0 through 0.83.0 (6 releases). On the way to 0.96.0: 5 required changes, 0 output changes an option keeps, 1 changes no option keeps, 3 new warnings, 16 changes that need nothing. Each item names the release that made it. All changes ยท Machine-readable list
Incomplete list: the changes of the releases after yours through 0.95.0 are not all listed yet. Read the breaking changes of those releases in the changelog too; every change after 0.95.0 is listed.
Keep your current output¶
No option is needed to keep your output; check the changes below.
Required changes¶
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
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
Changes no option keeps¶
--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
New warnings (act before the planned removal)¶
- Running datamodel-code-generator on Python 3.10 now emits FutureWarning (0.84.0): Run datamodel-code-generator on Python 3.11 or newer. details
- Genson installation now emits FutureWarning (0.95.0): Declare the genson extra if you generate from JSON, YAML, CSV or dict data. details
- Jinja2 installation now emits FutureWarning (0.95.0): Declare the jinja2 extra if you use custom templates. details
Also changed, no action needed¶
- --generate-client httpx2 and the --client-* options (and their [tool.datamodel-codegen] keys and generate() options) is experimental (0.84.0) details
- --generate-server fastapi and the --server-* options (and their [tool.datamodel-codegen] keys and generate() options) is experimental (0.84.0) details
- New dated presets
standard-py3XX-20261015andpractical-py3XX-20261015(0.85.0) details - NamingHintWarning is experimental (0.86.0) details
- --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) details
- New dated presets
standard-py3XX-20261017andpractical-py3XX-20261017(0.86.0) details - New dated presets
standard-py3XX-20261027andpractical-py3XX-20261027(0.87.0) details - New dated presets
standard-py3XX-20261104andpractical-py3XX-20261104(0.90.0) details - New dated presets
standard-py3XX-20261106andpractical-py3XX-20261106(0.91.0) details - --generate-client httpx2 with --input-file-type asyncapi, and --client-asyncapi-perspective is experimental (0.92.0) details
- --untrusted-input is experimental (0.92.0) details
- generate_dynamic_module(), DynamicModule, and register_module=True is experimental (0.92.0) details
- New dated presets
standard-py3XX-20261111andpractical-py3XX-20261111(0.94.0) details - argcomplete installation is scheduled to change (0.95.0) details
- New dated presets
standard-py3XX-20261112andpractical-py3XX-20261112(0.95.0) details - Patterns holding a quote are written without an escaped quote (0.96.0) details