fix empty operationId

This commit is contained in:
wing328 2015-07-27 11:21:51 +08:00
parent 31200acc1a
commit d0baa48fcd
2 changed files with 15 additions and 5 deletions

View File

@ -1278,10 +1278,9 @@ public class DefaultCodegen {
} else { } else {
m.emptyVars = true; m.emptyVars = true;
} }
} public static String camelize(String word) {
return camelize(word, false);
} }
/** /**
* Remove characters not suitable for variable or method name from the input and camelize it * Remove characters not suitable for variable or method name from the input and camelize it
* *
@ -1301,7 +1300,18 @@ public class DefaultCodegen {
name = name.substring(0, 1).toLowerCase() + name.substring(1); name = name.substring(0, 1).toLowerCase() + name.substring(1);
} }
return name; return name;
} public static String camelize(String word, boolean lowercaseFirstLetter) { }
public static String camelize(String word) {
return camelize(word, false);
}
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) // Replace all slashes with dots (package separator)
Pattern p = Pattern.compile("\\/(.?)"); Pattern p = Pattern.compile("\\/(.?)");
Matcher m = p.matcher(word); Matcher m = p.matcher(word);