mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Merge pull request #1993 from jaz-ah/issue-1992
[Swift] fix issue 1992 - ensure that our variable names don't match the names…
This commit is contained in:
commit
62e3bf2543
@ -189,7 +189,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "Swagger" + name; // add an underscore to the name
|
||||
return "_" + name; // add an underscore to the name
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -264,7 +264,11 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
codegenProperty.allowableValues.put("values", swiftEnums);
|
||||
codegenProperty.datatypeWithEnum =
|
||||
StringUtils.left(codegenProperty.datatypeWithEnum, codegenProperty.datatypeWithEnum.length() - "Enum".length());
|
||||
if (reservedWords.contains(codegenProperty.datatypeWithEnum)) {
|
||||
// Ensure that the enum type doesn't match a reserved word or
|
||||
// the variable name doesn't match the generated enum type or the
|
||||
// Swift compiler will generate an error
|
||||
if (reservedWords.contains(codegenProperty.datatypeWithEnum) ||
|
||||
name.equals(codegenProperty.datatypeWithEnum)) {
|
||||
codegenProperty.datatypeWithEnum = escapeReservedWord(codegenProperty.datatypeWithEnum);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user