Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript-fetch: Escape operation-id if clashing with model names #6004

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
macjohnny marked this conversation as resolved.
Show resolved Hide resolved
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