diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCppCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCppCodegen.java index 540bfa93f16..1c44d1587c4 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCppCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCppCodegen.java @@ -17,77 +17,90 @@ public AbstractCppCodegen() { */ setReservedWordsLowerCase( Arrays.asList( + "alignas", + "alignof", + "and", + "and_eq", + "asm", "auto", + "bitand", + "bitor", + "bool", "break", "case", + "catch", "char", + "char16_t", + "char32_t", + "class", + "compl", + "concept", "const", + "constexpr", + "const_cast", "continue", + "decltype", "default", + "delete", "do", "double", + "dynamic_cast", "else", "enum", + "explicit", + "export", "extern", + "false", "float", "for", + "friend", "goto", "if", + "inline", "int", "long", - "register", - "return", - "short", - "signed", - "sizeof", - "static", - "struct", - "switch", - "typedef", - "union", - "unsigned", - "void", - "volatile", - "while", - "asm", - "bool", - "catch", - "class", - "const_cast", - "delete", - "dynamic_cast", - "explicit", - "false", - "friend", - "inline", "mutable", "namespace", "new", + "noexcept", + "not", + "not_eq", + "nullptr", "operator", + "or", + "or_eq", "private", - "public", "protected", + "public", + "register", "reinterpret_cast", + "requires", + "return", + "short", + "signed", + "sizeof", + "static", + "static_assert", "static_cast", + "struct", + "switch", "template", "this", + "thread_local", "throw", "true", "try", + "typedef", "typeid", "typename", + "union", + "unsigned", "using", "virtual", + "void", + "volatile", "wchar_t", - "and", - "and_eq", - "bitand", - "bitor", - "compl", - "not", - "not_eq", - "or", - "or_eq", + "while", "xor", "xor_eq") ); @@ -129,6 +142,10 @@ public String escapeReservedWord(String name) { @Override public String toOperationId(String operationId) { + if (isReservedWord(operationId)) { + LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + escapeReservedWord(operationId)); + return escapeReservedWord(operationId); + } return sanitizeName(super.toOperationId(operationId)); }