[typescript-angular] Incorrect OperationId Generated (starting with number) (#2130)

append _ at the beginning, as reserved keyword
This commit is contained in:
karismann
2019-02-12 19:26:45 +01:00
committed by William Cheng
parent add63cb981
commit de33360883
3 changed files with 51 additions and 3 deletions

View File

@@ -407,9 +407,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
// append _ at the beginning, e.g. _return
if (isReservedWord(operationId)) {
// method name cannot use reserved keyword or word starting with number, e.g. return or 123return
// append _ at the beginning, e.g. _return or _123return
if (isReservedWord(operationId) || operationId.matches("^\\d.*")) {
return escapeReservedWord(camelize(sanitizeName(operationId), true));
}