forked from loafle/openapi-generator-original
Merge pull request #3941 from wing328/swfit_fix_num_enum
[Swift] support number value for enum
This commit is contained in:
@@ -384,10 +384,18 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public String toSwiftyEnumName(String value) {
|
||||
if (value.matches("^-?\\d*\\.{0,1}\\d+.*")) { // starts with number
|
||||
value = "Number" + value;
|
||||
value = value.replaceAll("-", "Minus");
|
||||
value = value.replaceAll("\\+", "Plus");
|
||||
value = value.replaceAll("\\.", "Dot");
|
||||
}
|
||||
|
||||
// Prevent from breaking properly cased identifier
|
||||
if (value.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
|
||||
return value;
|
||||
}
|
||||
|
||||
char[] separators = {'-', '_', ' ', ':'};
|
||||
return WordUtils.capitalizeFully(StringUtils.lowerCase(value), separators).replaceAll("[-_ :]", "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user