Fix the function name starting with numbers (#1513)

* update elixir samples

* fix function name starting with numbers

* add new files
This commit is contained in:
William Cheng
2018-11-23 17:32:51 +08:00
committed by GitHub
parent 5aa1da7c2e
commit cf04ba30db
13 changed files with 204 additions and 18 deletions

View File

@@ -431,7 +431,19 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
throw new RuntimeException("Empty method name (operationId) not allowed");
}
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId));
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId));
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId));
}
/**