[Rust Server] Fix #5947 multi tag generate multi method issue. (#5928)

* [Rust Server] Fix issue with multiple tags on an operation generating duplicate methods.

* [Rust Server] Add test case yaml with multiple tags on a single operation.
This commit is contained in:
Andy.Yang.cn 2020-04-23 01:00:21 +08:00 committed by GitHub
parent e38498dd5d
commit 38dfed4104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 1 deletions

View File

@ -1111,6 +1111,27 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
return dataType != null && dataType.equals(typeMapping.get("File").toString());
}
/**
* Add operation to group
*
* @param tag name of the tag
* @param resourcePath path of the resource
* @param operation OAS Operation object
* @param co Codegen Operation object
* @param operations map of Codegen operations
*/
@SuppressWarnings("static-method")
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation
co, Map<String, List<CodegenOperation>> operations) {
// only generate operation for the first tag of the tags
if (tag != null && co.tags.size() > 1 && !tag.equals(co.tags.get(0).getName())) {
LOGGER.info("generated skip additional tag `" + tag + "` with operationId=" + co.operationId);
return;
}
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
}
// This is a really terrible hack. We're working around the fact that the
// base version of `fromRequestBody` checks to see whether the body is a
// ref. If so, it unwraps the reference and replaces it with its inner

View File

@ -362,7 +362,7 @@ paths:
type: string
required: true
get:
tags: [Repo]
tags: [Repo, Info]
operationId: GetRepoInfo
responses:
"200":

View File

@ -384,6 +384,7 @@ paths:
description: OK
tags:
- Repo
- Info
components:
schemas:
EnumWithStarObject:

View File

@ -0,0 +1,8 @@
# info_api
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------