[ 
https://issues.apache.org/jira/browse/SCB-1031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16696127#comment-16696127
 ] 

ASF GitHub Bot commented on SCB-1031:
-------------------------------------

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:
us...@infra.apache.org


> The Response's properties was overrided wrong between @APIOperation and 
> @Resoponse on the controller method
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: SCB-1031
>                 URL: https://issues.apache.org/jira/browse/SCB-1031
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Java-Chassis
>            Reporter: jeho0815
>            Assignee: jeho0815
>            Priority: Major
>
> @ApiResponse(code = 200, message = "200 is ok............", response = 
> String.class, responseHeaders = @ResponseHeader(name = "x-user-domain", 
> response = String.class))
>  @ApiOperation(nickname="getHelloworld", value="test", notes="this is a 
> test", response = Integer.class, code = 200, 
>  responseHeaders =
> {@ResponseHeader(name = "x-user-name", response = String.class), 
> @ResponseHeader(name = "x-user-id", response = String.class)}
> )
>  
> swagger 's response's descritpion will be default "resoponse of 200", the 
> best descritpion  should be "200 is ok............"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to