add missing sanitization for operationId

This commit is contained in:
hideya kawahara 2016-02-11 19:50:14 +09:00
parent d05596dad4
commit aa09678b51

View File

@ -293,6 +293,21 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
return initialCaps(name) + "API";
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
if (reservedWords.contains(operationId)) {
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
}
return camelize(sanitizeName(operationId), true);
}
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
path = normalizePath(path); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.