About JSON to Swift
Swift's Codable protocol turns a struct into a JSON decoder with no extra code, provided the struct actually matches the data. When it does not, decoding throws rather than degrading, so accuracy matters more here than in a dynamically typed language.
Fields missing from some array elements are emitted as optionals, which is what stops decoding failing on a response that omits them.
Where a JSON key is not a valid Swift property name it is camel-cased, and a CodingKeys enum is generated to map every property back to its original key. Without that enum the renamed property simply never decodes.
How to generate Swift types
Paste your JSON
A whole array is better than one object — more samples means a more accurate type.
Name the root type
Nested objects are named automatically from the keys that hold them.
Copy the definitions
Types are emitted children first, so the file compiles in order.