Skip to content

Upgrading from 0.48.0 through 0.51.0 to 0.96.0

For datamodel-code-generator 0.48.0 through 0.51.0 (4 releases). On the way to 0.96.0: 5 required changes, 0 output changes an option keeps, 1 changes no option keeps, 14 new warnings, 33 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 of models.ItemSchema or models.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-map can pin individual names.
  • Pull requests and issues: #6777
  • Source: the release notes

New warnings (act before the planned removal)

  • Default formatters now emits FutureWarning (0.52.0): Set formatters explicitly, for example black and isort or builtin. details
  • Pydantic v2 default for --use-annotated now emits DeprecationWarning (0.52.1): Explicitly pass --use-annotated or --no-use-annotated. details
  • PythonVersion.has_type_alias now emits DeprecationWarning (0.52.1) Only if you use PythonVersion.has_type_alias. details
  • JSON Schema Draft 2020-12 items array tuple validation now emits UserWarning (0.53.0): Use prefixItems. details
  • OpenAPI 3.1 nullable keyword now emits DeprecationWarning (0.53.0): Use type arrays such as type: ["string", "null"]. details
  • Remote $ref fetching without --allow-remote-refs now emits FutureWarning (0.56.0): Pass --allow-remote-refs for trusted remote schemas, or --no-allow-remote-refs to block HTTP(S) $ref fetching. details
  • JSON configuration values accepted by legacy validation now emits FutureWarning (0.65.0): Update the JSON configuration to match --output-format-json-schema config. details
  • Black <24.3.0 now emits FutureWarning (0.78.0): Upgrade Black to >=24.3.0 before the later support change. details
  • Black/isort installation now emits FutureWarning (0.78.0): Declare the black/isort extras for the external formatters you select. details
  • isort <6 now emits FutureWarning (0.78.0): Upgrade isort to >=6,<9 before the later support change. details
  • DCG runtime Pydantic <2.8.2 now emits FutureWarning (0.78.0): Upgrade DCG runtime Pydantic to >=2.8.2; generated-code targets are unchanged. details
  • 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

  • --input-file-type asyncapi is experimental (0.59.0) details
  • --input-file-type avro is experimental (0.59.0) details
  • --input-file-type protobuf is experimental (0.59.0) details
  • --input-file-type xmlschema is experimental (0.59.0) details
  • --input-file-type mcp-tools is experimental (0.60.0) details
  • New dated presets standard-py3XX-20260619 and practical-py3XX-20260619 (0.64.1) details
  • --generate-schema-validators is experimental (0.66.1) details
  • --schema-validator-type is experimental (0.66.1) details
  • --use-missing-sentinel is experimental (0.66.1) details
  • datamodel-code-generator[httpx2] is experimental (0.72.0) details
  • --use-type-alias-type is experimental (0.72.1) details
  • [tool.datamodel-codegen.jobs], --job, --all-jobs is experimental (0.72.3) details
  • datamodel-codegen.lock, --lockfile, --update-lock, and --locked is experimental (0.72.3) details
  • --set-default-enum-member is scheduled to change (0.76.0) details
  • --install-skill, --skill-scope, and --overwrite-skill is experimental (0.76.0) details
  • New dated presets standard-py3XX-20260826 and practical-py3XX-20260826 (0.76.0) details
  • New dated presets standard-py3XX-20260909 and practical-py3XX-20260909 (0.78.0) details
  • --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-20261015 and practical-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-20261017 and practical-py3XX-20261017 (0.86.0) details
  • New dated presets standard-py3XX-20261027 and practical-py3XX-20261027 (0.87.0) details
  • New dated presets standard-py3XX-20261104 and practical-py3XX-20261104 (0.90.0) details
  • New dated presets standard-py3XX-20261106 and practical-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-20261111 and practical-py3XX-20261111 (0.94.0) details
  • argcomplete installation is scheduled to change (0.95.0) details
  • New dated presets standard-py3XX-20261112 and practical-py3XX-20261112 (0.95.0) details
  • Patterns holding a quote are written without an escaped quote (0.96.0) details