mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
a3d0f1d4bd
* Split up model template into partials * Change models from class to struct. This fixes issue https://github.com/swagger-api/swagger-codegen/issues/6941. In this change, we make our Swift4 generated model objects struct instead of class. However, in order to do this, we needed to handle the following edge cases: * Inheritance and polymorphism (allOf) * With classes, we use inheritance. So therefore, the parent properties are ONLY on the parent generated class, and the model object which derives from the parent class picks up those properties through inheritance. * However, structs do not support inheritance. So we simply duplicate the parent allOf properties in the child struct. * We have to handle the case where the property name on the struct may be different than the property name in the JSON. By default, the Codable protocol assumes that the JSON property name is the same as the struct property name. If they need to be different, then we generate a CodingKeys string enum, which contains the mapping between struct property name and JSON property name. * additionalProperties. We cannot use the default Codable implementation for the additionalProperties, since it will look for an actual dictionary called "additionalProperties" in the JSON. Therefore, for model objects which have additionalProperties, we must generate our own implementation for the Decodable and Encodable protocols. I have run ./bin/swift4-all.sh and ./bin/swift4-test.sh to re-generate all of the sources, and I have verified that the generated code in samples/clients/test/swift4/default builds and the unit tests pass. * Update VERSION in .swagger-codegen * Update generated code for swift4-test schema |
||
---|---|---|
.. | ||
.swagger-codegen | ||
PetstoreClient/Classes/Swaggers | ||
SwaggerClientTests | ||
.gitignore | ||
.swagger-codegen-ignore | ||
Cartfile | ||
git_push.sh | ||
PetstoreClient.podspec |