Commit 22830f2
authored
Propagate nullability through references (#300)
Propagate nullability through references
### Motivation
Fixes #288.
### Modifications
Refactors how we decide whether to mark a type as optional, and adds the ability to "peek" through references to decide the nullability of the reference schema.
Also added an article describing the overall logic as a starting point, will be expanded with a few more changes coming in this area in future PRs.
### Result
We now correctly mark an object property as optional if it points at an optional schema through a reference. Previously, it was always marked as required, which caused decoding to fail e.g. in the GitHub OpenAPI doc.
### Test Plan
Added and adjusted unit tests.
Reviewed by: simonjbeaumont
Builds:
✔︎ pull request validation (5.8) - Build finished.
✔︎ pull request validation (5.9) - Build finished.
✔︎ pull request validation (compatibility test) - Build finished.
✔︎ pull request validation (docc test) - Build finished.
✔︎ pull request validation (nightly) - Build finished.
✔︎ pull request validation (soundness) - Build finished.
✖︎ pull request validation (integration test) - Build finished.
#3001 parent b4ad524 commit 22830f2
File tree
14 files changed
+289
-16
lines changed- Sources
- _OpenAPIGeneratorCore/Translator
- CommonTranslations
- Content
- Parameters
- Responses
- TypeAssignment
- swift-openapi-generator/Documentation.docc/Development
- Tests
- OpenAPIGeneratorCoreTests/Translator/TypeAssignment
- OpenAPIGeneratorReferenceTests
14 files changed
+289
-16
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
96 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| 241 | + | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
| |||
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| 131 | + | |
126 | 132 | | |
127 | 133 | | |
128 | 134 | | |
| |||
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| 141 | + | |
135 | 142 | | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
139 | 146 | | |
| 147 | + | |
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
| 154 | + | |
146 | 155 | | |
147 | 156 | | |
148 | 157 | | |
| |||
151 | 160 | | |
152 | 161 | | |
153 | 162 | | |
| 163 | + | |
154 | 164 | | |
155 | 165 | | |
156 | 166 | | |
157 | 167 | | |
| 168 | + | |
158 | 169 | | |
159 | 170 | | |
160 | 171 | | |
161 | 172 | | |
162 | 173 | | |
| 174 | + | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
| |||
169 | 181 | | |
170 | 182 | | |
171 | 183 | | |
| 184 | + | |
172 | 185 | | |
173 | 186 | | |
174 | 187 | | |
175 | 188 | | |
176 | 189 | | |
| 190 | + | |
177 | 191 | | |
178 | 192 | | |
179 | 193 | | |
180 | 194 | | |
181 | 195 | | |
| 196 | + | |
182 | 197 | | |
183 | 198 | | |
184 | 199 | | |
| |||
250 | 265 | | |
251 | 266 | | |
252 | 267 | | |
| 268 | + | |
253 | 269 | | |
254 | 270 | | |
255 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
256 | 275 | | |
257 | 276 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
264 | 281 | | |
265 | 282 | | |
266 | 283 | | |
| |||
277 | 294 | | |
278 | 295 | | |
279 | 296 | | |
280 | | - | |
| 297 | + | |
281 | 298 | | |
282 | 299 | | |
283 | 300 | | |
| |||
Lines changed: 47 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | | - | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| |||
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
243 | 287 | | |
244 | 288 | | |
245 | 289 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
0 commit comments