forked from loafle/openapi-generator-original
add logic to camelize path variables for feign client (#5301)
This commit is contained in:
parent
ce41a343d8
commit
2e8eea9c18
@ -242,14 +242,14 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||||
super.postProcessOperations(objs);
|
super.postProcessOperations(objs);
|
||||||
if(usesAnyRetrofitLibrary()) {
|
if (usesAnyRetrofitLibrary()) {
|
||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
if (operations != null) {
|
if (operations != null) {
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation operation : ops) {
|
for (CodegenOperation operation : ops) {
|
||||||
if (operation.hasConsumes == Boolean.TRUE) {
|
if (operation.hasConsumes == Boolean.TRUE) {
|
||||||
|
|
||||||
if ( isMultipartType(operation.consumes) ) {
|
if (isMultipartType(operation.consumes)) {
|
||||||
operation.isMultipart = Boolean.TRUE;
|
operation.isMultipart = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -264,6 +264,27 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// camelize path variables for Feign client
|
||||||
|
if ("feign".equals(getLibrary())) {
|
||||||
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
for (CodegenOperation op : operationList) {
|
||||||
|
String path = new String(op.path);
|
||||||
|
String[] items = path.split("/", -1);
|
||||||
|
String opsPath = "";
|
||||||
|
int pathParamIndex = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < items.length; ++i) {
|
||||||
|
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
|
||||||
|
// camelize path variable
|
||||||
|
items[i] = "{" + camelize(items[i].substring(1, items[i].length()-1), true) + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
op.path = StringUtils.join(items, "/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user