Commit 445e55b
authored
[Generator] Fix nested coding (#271)
[Generator] Fix nested coding
### Motivation
Fixes #263. Depends on apple/swift-openapi-runtime#50.
### Modifications
This started as a "simple" fix for Date coding, which was broken when nested in oneOf/allOf/anyOf, and resulted in a refactoring of how we generate custom Codable implementations.
I wrote it up in a new article for maintainers, that has all the detail that should explain this PR: https://github.com/apple/swift-openapi-generator/blob/d735ac18354cee03bd3b087e229948593394e9c0/Sources/swift-openapi-generator/Documentation.docc/Development/Generating-custom-Codable-conformance-methods.md
### Result
Now Dates are correctly encoded/decoded even when nested in oneOf/allOf/anyOf.
### Test Plan
Updated reference tests to cover more of these tricky cases (that's why they were added to the file-based reference tests), updated snippet tests as well, and unit tests.
Verified that the motivating use case - the k8s API, now parses responses correctly when Dates are nested in allOf.
Reviewed by: glbrntt
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 (integration test) - Build finished.
✔︎ pull request validation (nightly) - Build finished.
✔︎ pull request validation (soundness) - Build finished.
#2711 parent 2b00744 commit 445e55b
File tree
13 files changed
+659
-100
lines changed- Sources
- _OpenAPIGeneratorCore/Translator
- CommonTranslations
- CommonTypes
- TypeAssignment
- swift-openapi-generator/Documentation.docc/Development
- Tests
- OpenAPIGeneratorCoreTests/Translator/TypeAssignment
- OpenAPIGeneratorReferenceTests
- Resources
- Docs
- ReferenceSources/Petstore
- PetstoreConsumerTests
13 files changed
+659
-100
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
Lines changed: 22 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| 94 | + | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
92 | | - | |
| 99 | + | |
93 | 100 | | |
94 | | - | |
| 101 | + | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| |||
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
104 | | - | |
| 111 | + | |
105 | 112 | | |
106 | 113 | | |
107 | 114 | | |
| |||
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
127 | | - | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
| |||
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
150 | | - | |
| 157 | + | |
151 | 158 | | |
152 | 159 | | |
153 | 160 | | |
| |||
183 | 190 | | |
184 | 191 | | |
185 | 192 | | |
186 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
187 | 198 | | |
188 | 199 | | |
189 | 200 | | |
190 | 201 | | |
191 | | - | |
| 202 | + | |
192 | 203 | | |
193 | 204 | | |
194 | 205 | | |
| |||
205 | 216 | | |
206 | 217 | | |
207 | 218 | | |
208 | | - | |
209 | | - | |
210 | 219 | | |
211 | 220 | | |
212 | 221 | | |
| |||
232 | 241 | | |
233 | 242 | | |
234 | 243 | | |
235 | | - | |
| 244 | + | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
239 | | - | |
| 248 | + | |
240 | 249 | | |
241 | 250 | | |
242 | 251 | | |
| |||
0 commit comments