diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index b1ab5e4fa818..a2f03cfdd3fa 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -235,9 +235,24 @@ public Map postProcessOperationsWithModels(Map o this.updateOperationParameterEnumInformation(operations); this.addOperationObjectResponseInformation(operations); this.addOperationPrefixParameterInterfacesInformation(operations); + this.escapeOperationIds(operations); return operations; } + private void escapeOperationIds(Map operations) { + Map _operations = (Map) operations.get("operations"); + List operationList = (List) _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 operations) { // This method will add extra infomation to the operations.imports array. // The api template uses this infomation to import all the required