Skip to content
Merged
Show file tree
Hide file tree
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 @@ -450,7 +450,15 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);

String underscoredOperationId = underscore(op.operationId);
ArrayList<MethodOperation> pathMethods = pathMethodOpMap.get(path);
String axumPath = op.path;
for (CodegenParameter param : op.pathParams) {
// Replace {baseName} with {paramName} for format string
String paramSearch = "{" + param.baseName + "}";
String paramReplace = "{" + param.paramName + "}";

axumPath = axumPath.replace(paramSearch, paramReplace);
}
ArrayList<MethodOperation> pathMethods = pathMethodOpMap.get(axumPath);

// Prevent multiple declarations of the same operation
if (pathMethods != null && pathMethods.stream().anyMatch(pathMethod ->
Expand All @@ -463,14 +471,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation

if (!op.isCallbackRequest) {
// group route by path
String axumPath = op.path;
for (CodegenParameter param : op.pathParams) {
// Replace {baseName} with {paramName} for format string
String paramSearch = "{" + param.baseName + "}";
String paramReplace = "{" + param.paramName + "}";

axumPath = axumPath.replace(paramSearch, paramReplace);
}
pathMethodOpMap
.computeIfAbsent(axumPath, (key) -> new ArrayList<>())
.add(new MethodOperation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public void testPreventDuplicateOperationDeclaration() throws IOException {
String routerSpec = linearize("Router::new() " +
".route(\"/api/test\", " +
"delete(test_delete::<I, A, E, C>).post(test_post::<I, A, E, C>) ) " +
".route(\"/api/test/{test_id}\", " +
"get(test_get::<I, A, E, C>) ) " +
".with_state(api_impl)");
TestUtils.assertFileExists(outputPath);
TestUtils.assertFileContains(outputPath, routerSpec);
Expand Down
19 changes: 19 additions & 0 deletions modules/openapi-generator/src/test/resources/3_1/issue_21144.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ paths:
description: "post"
security:
- apiKey: []
/api/test/{testId}:
get:
tags:
- firsttag
- secondtag
- thirdtag
operationId: "testGet"
description: "Get method"
parameters:
- name: testId
in: path
required: true
schema:
type: string
responses:
200:
description: "get"
security:
- apiKey: [ ]
components:
securitySchemes:
apiKey:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ where
post(create_repo::<I, A, E>)
)
.route("/repos/{repo_id}",
get(get_repo_info::<I, A, E>).get(get_repo_info::<I, A, E>)
get(get_repo_info::<I, A, E>)
)
.route("/required_octet_stream",
put(required_octet_stream_put::<I, A, E>)
Expand Down
Loading