Escape clashing model names (#6004)

Closes #6002
This commit is contained in:
Harald Fernengel
2020-04-22 14:23:24 +02:00
committed by GitHub
parent 40be1c311e
commit 63b4429775

View File

@@ -235,9 +235,24 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
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