Closed
Description
Thank you as always.
Description
I generate Sagger Code(Use 2.3.0 and 3.0.0)
Enum is included in the model fails to build.
Like this.
public enum ModelType: String, Codable {
case list = "list"
case map = "map"
case camera = "camera"
case setting = "setting"
case other = "other"
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: String.self)
type = try container.decodeIfPresent(String.self, forKey: "type")
...
}
Error message:
"Cannot assign value of type 'String?' to type 'Button.ModelType?'"
Swagger-codegen version
3.0.0 2.3.0 both latest version.
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli-3.0.0-20170924.102354-5.jar generate -i swagger.yaml -l swift4 -o temp/
java -jar swagger-codegen-cli-2.3.0-20171002.073400-174.jar generate -i swagger.yaml -l swift4 -o temp/
Steps to reproduce
run the above command
Related issues/PRs
Suggest a fix/enhancement
I replace the code.
e.g.
type = try container.decodeIfPresent(String.self, forKey: "type")
↓
type = try container.decodeIfPresent(Button.ModelType.self, forKey: "type")
I am happy that it can be done automatically :)