openapi-generator/samples/client/petstore/swift4/rxswift
ehyche a3d0f1d4bd Swift4: make generated models structs instead of classes (#7345)
* 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
2018-01-25 21:33:11 +08:00
..
.swagger-codegen Swift4: make generated models structs instead of classes (#7345) 2018-01-25 21:33:11 +08:00
PetstoreClient/Classes/Swaggers Swift4: make generated models structs instead of classes (#7345) 2018-01-25 21:33:11 +08:00
SwaggerClientTests [Swift4]Update templates for swift 4 (#6921) 2017-11-21 11:33:52 +08:00
.gitignore Add a swift4 client generator (#6010) 2017-07-09 01:33:52 +08:00
.swagger-codegen-ignore Add a swift4 client generator (#6010) 2017-07-09 01:33:52 +08:00
Cartfile [Swift4]Update templates for swift 4 (#6921) 2017-11-21 11:33:52 +08:00
git_push.sh [Swift4]Update templates for swift 4 (#6921) 2017-11-21 11:33:52 +08:00
PetstoreClient.podspec Update samples using latest codegen and templates (#7071) 2017-11-29 14:49:45 +08:00