Commit 8df1ddd
committed
[BUG][DART] Fix nested-map ! suffix to apply to whole nullable expression
Cubic review on OpenAPITools#23671 caught that the prior shape
json[X] == null
? null
: (json[X] as Map).map(...).cast<...>()!
applied the trailing ! only to the else branch, so a required
non-nullable Map<String, Map<...>> field could still be assigned null
from the ? branch.
Restructure to a single nullable expression that matches the existing
mapCastOfType pattern in the same file:
(json[X] as Map?)?.map((k, v) => MapEntry(k as String, (v as Map).cast<String, T>()))
{{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}
{{^required}}{{#defaultValue}} ?? <default>{{/defaultValue}}{{/required}}
Now ! correctly applies to the whole nullable expression, ?? feeds the
default consistently with the other map branches, and the optional case
collapses to a single nullable expression instead of a ternary.1 parent b33ba0c commit 8df1ddd
5 files changed
Lines changed: 5 additions & 19 deletions
File tree
- modules/openapi-generator/src/main/resources/dart2/serialization/native
- samples/openapi3/client/petstore/dart2/petstore_client_lib_fake
- .openapi-generator
- lib/model
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 231 | + | |
234 | 232 | | |
235 | 233 | | |
236 | 234 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 69 | + | |
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 74 | + | |
77 | 75 | | |
78 | 76 | | |
79 | 77 | | |
| |||
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 62 | + | |
| 63 | + | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| |||
0 commit comments