Commit 84ca7a4
Fix required fields inconsistently rendering defaults (#3048)
__set_validate_default_on_fields set validate_default=True on fields
with model references without checking field.required, causing required
model-ref fields to render defaults while required scalar fields didn't.
Skip required fields (unless use_default_with_required) so all required
fields consistently have no defaults rendered.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent af51cd7 commit 84ca7a4
2 files changed
Lines changed: 4 additions & 2 deletions
File tree
- src/datamodel_code_generator/parser
- tests/data/expected/main/graphql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2177 | 2177 | | |
2178 | 2178 | | |
2179 | 2179 | | |
| 2180 | + | |
| 2181 | + | |
2180 | 2182 | | |
2181 | 2183 | | |
2182 | 2184 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
0 commit comments