Skip to content

Commit 8c60b1b

Browse files
docs: update CHANGELOG.md for 0.53.0
1 parent a6a7b04 commit 8c60b1b

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,91 @@ All notable changes to this project are documented in this file.
44
This changelog is automatically generated from GitHub Releases.
55

66
---
7+
## [0.53.0](https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.53.0) - 2026-01-12
8+
9+
## Breaking Changes
10+
11+
12+
13+
14+
15+
### Custom Template Update Required
16+
* Parser subclass signature change - The `Parser` base class now requires two generic type parameters: `Parser[ParserConfigT, SchemaFeaturesT]` instead of just `Parser[ParserConfigT]`. Custom parser subclasses must be updated to include the second type parameter. (#2929)
17+
```python
18+
# Before
19+
class MyCustomParser(Parser["MyParserConfig"]):
20+
...
21+
# After
22+
class MyCustomParser(Parser["MyParserConfig", "JsonSchemaFeatures"]):
23+
...
24+
```
25+
* New abstract `schema_features` property required - Custom parser subclasses must now implement the `schema_features` abstract property that returns a `JsonSchemaFeatures` (or subclass) instance. (#2929)
26+
```python
27+
from functools import cached_property
28+
from datamodel_code_generator.parser.schema_version import JsonSchemaFeatures
29+
from datamodel_code_generator.enums import JsonSchemaVersion
30+
class MyCustomParser(Parser["MyParserConfig", "JsonSchemaFeatures"]):
31+
@cached_property
32+
def schema_features(self) -> JsonSchemaFeatures:
33+
return JsonSchemaFeatures.from_version(JsonSchemaVersion.Draft202012)
34+
```
35+
* Parser `_create_default_config` refactored to use class variable - Subclasses that override `_create_default_config` should now set the `_config_class_name` class variable instead. The base implementation uses this variable to dynamically instantiate the correct config class. (#2929)
36+
```python
37+
# Before
38+
@classmethod
39+
def _create_default_config(cls, options: MyConfigDict) -> MyParserConfig:
40+
# custom implementation...
41+
# After
42+
_config_class_name: ClassVar[str] = "MyParserConfig"
43+
# No need to override _create_default_config if using standard config creation
44+
```
45+
* Template condition for default values changed - If you use custom Jinja2 templates based on `BaseModel_root.jinja2` or `RootModel.jinja2`, the condition for including default values has changed from `field.required` to `(field.required and not field.has_default)`. Update your custom templates if you override these files. (#2960)
46+
47+
### Code Generation Changes
48+
* RootModel default values now included in generated code - Previously, default values defined in JSON Schema or OpenAPI specifications for root models were not being applied to the generated Pydantic code. Now these defaults are correctly included. For example, a schema defining a root model with `default: 1` will generate `__root__: int = 1` (Pydantic v1) or `root: int = 1` (Pydantic v2) instead of just `__root__: int` or `root: int`. This may affect code that relied on the previous behavior where RootModel fields had no default values. (#2960)
49+
* Required fields with list defaults now use `default_factory` - Previously, required fields with list-type defaults (like `__root__: list[ID] = ['abc', 'efg']`) were generated with direct list assignments. Now they correctly use `Field(default_factory=lambda: ...)` which follows Python best practices for mutable defaults. This changes the structure of generated code for root models and similar patterns with list defaults. (#2958)
50+
Before:
51+
```python
52+
class Family(BaseModel):
53+
__root__: list[ID] = ['abc', 'efg']
54+
```
55+
After:
56+
```python
57+
class Family(BaseModel):
58+
__root__: list[ID] = Field(
59+
default_factory=lambda: [ID.parse_obj(v) for v in ['abc', 'efg']]
60+
)
61+
```
62+
63+
## What's Changed
64+
* Separate pytest-benchmark into dedicated benchmark dependency group by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2937
65+
* Support ClassVar for Pydantic v2 by @ubaumann in https://github.com/koxudaxi/datamodel-code-generator/pull/2920
66+
* Add schema version detection and feature flags by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2924
67+
* Fix MRO ordering for multiple inheritance in GraphQL and JSON Schema/OpenAPI by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2941
68+
* Add schema_features property to parsers for version detection by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2929
69+
* Fix $ref handling in request-response mode for readOnly/writeOnly schemas by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2942
70+
* Ensure codecov upload runs even when coverage check fails by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2944
71+
* Add FeatureMetadata to schema feature classes for doc generation by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2945
72+
* Add schema-docs auto-generation with pre-commit and CI by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2949
73+
* Add comprehensive feature metadata to schema version dataclasses by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2946
74+
* fix: move UnionMode import outside TYPE_CHECKING for Pydantic runtime… by @phil65 in https://github.com/koxudaxi/datamodel-code-generator/pull/2950
75+
* Fix IndexError when using --reuse-scope=tree with single file output by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2954
76+
* Add --use-closed-typed-dict option to control PEP 728 TypedDict generation by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2956
77+
* Fix RootModel default value not being applied by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2960
78+
* Fix required list fields ignoring empty default values by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2958
79+
* Add GenerateConfig lazy import from top-level module by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2961
80+
* Fix allOf array property merging to preserve child $ref by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2962
81+
* Fix array RootModel default value handling in parser by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2963
82+
* Fix bug in handling of graphql empty list defaults by @rpmcginty in https://github.com/koxudaxi/datamodel-code-generator/pull/2948
83+
84+
## New Contributors
85+
* @ubaumann made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/2920
86+
* @phil65 made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/2950
87+
88+
**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.52.2...0.53.0
89+
90+
---
91+
792
## [0.52.2](https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.52.2) - 2026-01-05
893

994
## What's Changed

0 commit comments

Comments
 (0)