github koxudaxi/datamodel-code-generator 0.59.0

4 hours ago

Breaking Changes

Code Generation Changes

  • Pattern key constraints now include propertyNames constraints - When a JSON Schema uses both patternProperties and propertyNames, the generated dict key type now merges constraints from both. Previously, propertyNames constraints such as minLength, maxLength, and $ref could be ignored when patternProperties was present. Regenerated code may produce stricter key types and reject data that was previously accepted by less-strict generated models. (#3192)
  • Typed additionalProperties now generates a typed __pydantic_extra__ field for Pydantic v2 models - When a JSON Schema defines schema-valued additionalProperties, generated Pydantic v2 models now include __pydantic_extra__: dict[str, <type>]. Previously, these models only allowed extra fields without typing their values. This changes generated output and makes Pydantic validate extra field values at runtime. (#3205)
  • Dataclass field ordering with --use-annotated may change - Dataclass field assignment detection now accounts for constraints moved into Annotated[...]. Generated dataclass fields may be reordered so fields without defaults come before fields with defaults. (#3203)

Default Behavior Changes

  • Auto-detection (--input-file-type auto) now recognizes AsyncAPI, Avro, and Protocol Buffers inputs - Inputs that previously fell back to JSON/YAML handling or failed detection may now be detected as one of these formats. (#3194, #3195, #3198)

Compatibility Notes

  • The temporary Pydantic minimum-version change from pydantic>=2,<3 to pydantic>=2.6,<3 was reverted before this release. The final dependency range for Python < 3.14 remains pydantic>=2,<3. (#3210, #3215)

What's Changed

New Contributors

Full Changelog: 0.58.0...0.59.0

Don't miss a new datamodel-code-generator release

NewReleases is sending notifications on new releases.