forked from loafle/openapi-generator-original
fix empty operationId in java codegen
This commit is contained in:
parent
d0baa48fcd
commit
a8f580032f
@ -1216,7 +1216,9 @@ public class DefaultCodegen {
|
||||
if (mappedType != null) {
|
||||
addImport(m, mappedType);
|
||||
}
|
||||
} /**
|
||||
}
|
||||
|
||||
/**
|
||||
* Underscore the given word.
|
||||
*
|
||||
* @param word The word
|
||||
@ -1307,11 +1309,6 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
public static String camelize(String word, boolean lowercaseFirstLetter) {
|
||||
// throw exception if method name is empty
|
||||
if (StringUtils.isEmpty(word)) {
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
// Replace all slashes with dots (package separator)
|
||||
Pattern p = Pattern.compile("\\/(.?)");
|
||||
Matcher m = p.matcher(word);
|
||||
|
@ -13,6 +13,8 @@ import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
@ -234,6 +236,11 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user