Skip to content

Commit

Permalink
Escape clashing model names (OpenAPITools#6004)
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldF authored and MikailBag committed May 31, 2020
1 parent 550c4b9 commit 189fe4d
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,24 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
this.updateOperationParameterEnumInformation(operations);
this.addOperationObjectResponseInformation(operations);
this.addOperationPrefixParameterInterfacesInformation(operations);
this.escapeOperationIds(operations);
return operations;
}

private void escapeOperationIds(Map<String, Object> operations) {
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
for (CodegenOperation op : operationList) {
String param = op.operationIdCamelCase + "Request";
if (op.imports.contains(param)) {
// we import a model with the same name as the generated operation, escape it
op.operationIdCamelCase += "Operation";
op.operationIdLowerCase += "operation";
op.operationIdSnakeCase += "_operation";
}
}
}

private void addOperationModelImportInfomation(Map<String, Object> operations) {
// This method will add extra infomation to the operations.imports array.
// The api template uses this infomation to import all the required
Expand Down

0 comments on commit 189fe4d

Please sign in to comment.