You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/11/22 17:05:30 UTC
[GitHub] wujimin commented on a change in pull request #999: [SCB-1031] resolve @ApiOperator @Response override wrong, if the prev…
wujimin commented on a change in pull request #999: [SCB-1031] resolve @ApiOperator @Response override wrong, if the prev…
URL: https://github.com/apache/servicecomb-java-chassis/pull/999#discussion_r235788636
##########
File path: swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/processor/annotation/AnnotationUtils.java
##########
@@ -127,7 +127,35 @@ public static void addResponse(Swagger swagger, ApiResponse apiResponse) {
public static void addResponse(Swagger swagger, Operation operation, ApiResponse apiResponse) {
ResponseConfig responseConfig = convert(apiResponse);
generateResponse(swagger, responseConfig);
- operation.response(responseConfig.getCode(), responseConfig.getResponse());
+ mergeResponse(operation, responseConfig);
+ }
+
+ private static void mergeResponse(Operation operation, ResponseConfig responseConfig) {
+ if (operation.getResponses() == null) {
+ operation.response(responseConfig.getCode(), responseConfig.getResponse());
+ return;
+ }
+ Response response = operation.getResponses().get(String.valueOf(responseConfig.getCode()));
+ if (response != null) {
+ Response targetResp = responseConfig.getResponse();
Review comment:
1.targetResp is source, right?
2.logic for (response == null) is simpler, better to process first and then return, and no need write "else"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services