forked from loafle/openapi-generator-original
include underscore when generating nodejs controller and service method
This commit is contained in:
parent
2af29fa831
commit
fe704eee1f
@ -2319,18 +2319,21 @@ public class DefaultCodegen {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("static-method")
|
@SuppressWarnings("static-method")
|
||||||
public String removeNonNameElementToCamelCase(String name) {
|
public String removeNonNameElementToCamelCase(String name) {
|
||||||
String nonNameElementPattern = "[-_:;#]";
|
return removeNonNameElementToCamelCase(name, "[-_:;#]");
|
||||||
name = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() { // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
}
|
||||||
|
|
||||||
|
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
|
||||||
|
String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String apply(String input) {
|
public String apply(String input) {
|
||||||
return StringUtils.capitalize(input);
|
return StringUtils.capitalize(input);
|
||||||
}
|
}
|
||||||
}), "");
|
}), "");
|
||||||
if (name.length() > 0) {
|
if (result.length() > 0) {
|
||||||
name = name.substring(0, 1).toLowerCase() + name.substring(1);
|
result = result.substring(0, 1).toLowerCase() + result.substring(1);
|
||||||
}
|
}
|
||||||
return name;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,4 +314,10 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
return super.postProcessSupportingFileData(objs);
|
return super.postProcessSupportingFileData(objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String removeNonNameElementToCamelCase(String name) {
|
||||||
|
return removeNonNameElementToCamelCase(name, "[-:;#]");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user