Commit 62b69a9
authored
Improve structured Swift representation for recursive type support (#334)
Improve structured Swift representation for recursive type support
### Motivation
The recursive type support required some improvements to our structured Swift representation layer, so I split out just these noisy, mechanical, but not very interesting changes separate from the actual recursive type support here, into this PR.
### Modifications
- Improves `IdentifierDescription` to be an enum of a "pattern" (usually a variable) and "type" (represents a type, like `Foo`, `any Foo`, `Foo?`, `[Foo]`, etc.) The lattern required more logic, so we propagate the distinction all the way to the renderer.
- Added `trailingClosure` support to a `FunctionCallDescription`.
- Introduced `ExistingTypeDescription`, kind of like the equivalent of `TypeUsage`, but on the structured Swift layer side. Moved to this type in a bunch of other types, most of which previously just had a `String`.
- Allowed defining a setter on a computed variable.
- Allowed marking an enum as indirect.
### Result
Added the functionality required for the next PR adding recursive type support.
But _mostly_ this should be a refactoring and apart from the next point, not change any functionality.
The most visible change to the reference tests is that more types are now fully qualified, such as going from `String` -> `Swift.String`.
### Test Plan
Adapted all tests, all still pass.
Reviewed by: simonjbeaumont
Builds:
✔︎ pull request validation (5.10) - Build finished.
✔︎ 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 (integration test) - Build finished.
✔︎ pull request validation (nightly) - Build finished.
✔︎ pull request validation (soundness) - Build finished.
#3341 parent d9d5daa commit 62b69a9
File tree
34 files changed
+795
-431
lines changed- Sources/_OpenAPIGeneratorCore
- Layers
- Renderer
- Translator
- ClientTranslator
- CommonTranslations
- CommonTypes
- Operations
- Parameters
- RequestBody
- Responses
- ServerTranslator
- TypeAssignment
- TypesTranslator
- Tests
- OpenAPIGeneratorCoreTests
- Renderer
- Translator/CommonTranslations
- OpenAPIGeneratorReferenceTests
- Resources/ReferenceSources/Petstore
34 files changed
+795
-431
lines changedLines changed: 227 additions & 29 deletions
Large diffs are not rendered by default.
Lines changed: 53 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| |||
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
139 | 150 | | |
140 | 151 | | |
| 152 | + | |
141 | 153 | | |
142 | 154 | | |
143 | 155 | | |
| |||
233 | 245 | | |
234 | 246 | | |
235 | 247 | | |
| 248 | + | |
| 249 | + | |
236 | 250 | | |
237 | 251 | | |
238 | 252 | | |
| |||
382 | 396 | | |
383 | 397 | | |
384 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
385 | 417 | | |
386 | 418 | | |
387 | 419 | | |
| |||
392 | 424 | | |
393 | 425 | | |
394 | 426 | | |
395 | | - | |
| 427 | + | |
396 | 428 | | |
397 | 429 | | |
398 | 430 | | |
| |||
419 | 451 | | |
420 | 452 | | |
421 | 453 | | |
422 | | - | |
| 454 | + | |
423 | 455 | | |
424 | 456 | | |
425 | 457 | | |
| |||
432 | 464 | | |
433 | 465 | | |
434 | 466 | | |
435 | | - | |
| 467 | + | |
| 468 | + | |
436 | 469 | | |
437 | 470 | | |
438 | 471 | | |
439 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
440 | 483 | | |
441 | 484 | | |
442 | 485 | | |
| |||
505 | 548 | | |
506 | 549 | | |
507 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
508 | 554 | | |
509 | 555 | | |
510 | 556 | | |
| |||
532 | 578 | | |
533 | 579 | | |
534 | 580 | | |
535 | | - | |
| 581 | + | |
536 | 582 | | |
537 | 583 | | |
538 | 584 | | |
| |||
663 | 709 | | |
664 | 710 | | |
665 | 711 | | |
666 | | - | |
| 712 | + | |
667 | 713 | | |
668 | 714 | | |
669 | 715 | | |
| |||
Lines changed: 15 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | | - | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | | - | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
104 | | - | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | | - | |
| 111 | + | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
112 | | - | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
116 | | - | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
129 | | - | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | | - | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
Lines changed: 17 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
| |||
170 | 173 | | |
171 | 174 | | |
172 | 175 | | |
173 | | - | |
| 176 | + | |
174 | 177 | | |
175 | 178 | | |
176 | 179 | | |
| |||
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
195 | | - | |
| 198 | + | |
196 | 199 | | |
197 | 200 | | |
198 | 201 | | |
| |||
201 | 204 | | |
202 | 205 | | |
203 | 206 | | |
204 | | - | |
| 207 | + | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| |||
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
218 | | - | |
| 221 | + | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
0 commit comments