Upgrading from 0.93.0 through 0.94.0 to 0.96.0¶
For datamodel-code-generator 0.93.0 through 0.94.0 (2 releases). On the way to 0.96.0: 4 required changes, 0 output changes an option keeps, 1 changes no option keeps, 2 new warnings, 4 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¶
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)¶
- 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¶
- 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