Bug Report Checklist
Description
EnumValues with special characters will produce enum var names with special characters which causes compile errors in Xcode.
In our example we have the following property:
"aspectRatio" : {
"type" : "string",
"enum" : [ "1:1", "4:5", "4:3", "9:16", "16:9" ]
}
... generating this code:
public enum AspectRatio: String, Codable, CaseIterable {
case _1:1 = "1:1"
case _4:5 = "4:5"
case _4:3 = "4:3"
case _9:16 = "9:16"
case _16:9 = "16:9"
}
openapi-generator version
5.3.1
Generation Details
swift5
Suggest a fix
Add .replaceAll("\\W+", "_") in public String toEnumVarName(String name, String datatype) in class Swift5ClientCodegen.
This is also done in the DefaultCodegen class and in some of the other generator classes.
Bug Report Checklist
full/minimal spec to reproduce the issue?Description
EnumValues with special characters will produce enum var names with special characters which causes compile errors in Xcode.
In our example we have the following property:
... generating this code:
openapi-generator version
5.3.1
Generation Details
swift5
Suggest a fix
Add
.replaceAll("\\W+", "_")inpublic String toEnumVarName(String name, String datatype)in classSwift5ClientCodegen.This is also done in the
DefaultCodegenclass and in some of the other generator classes.