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,9 +1278,8 @@ public class DefaultCodegen {
} else {
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
@ -1301,7 +1300,18 @@ public class DefaultCodegen {
name = name.substring(0, 1).toLowerCase() + name.substring(1);
}
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)
Pattern p = Pattern.compile("\\/(.?)");
Matcher m = p.matcher(word);

View File

@ -14,8 +14,8 @@ public class Pet {
private Long id = null;
private Category category = null;
private String name = null;
private List<String> photoUrls = new ArrayList<String>() ;
private List<Tag> tags = new ArrayList<Tag>() ;
private List<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
public enum StatusEnum {
available, pending, sold,
};