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 2022/06/22 07:53:14 UTC

[GitHub] [servicecomb-java-chassis] zhaozw opened a new pull request, #3109: [3108] support @RequestMapping annotation

zhaozw opened a new pull request, #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109

   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r907485222


##########
demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringMVCSchema.java:
##########
@@ -43,4 +43,16 @@ public class SpringMVCSchema {
   public String testApiExample(@RequestBody String name, HttpServletRequest request) {
     return null;
   }
+
+  @ApiResponses({
+      @ApiResponse(code = 200, response = String.class, message = "success",
+          examples = @Example({
+              @ExampleProperty(value = "wget http://localhost/springMvcSchema/testDefaultGetApiExample", mediaType = "text"),
+              @ExampleProperty(value = "{name:hello}", mediaType = "application/json"),
+              @ExampleProperty(value = "{name:hello}", mediaType = "json")})
+      )})
+  @RequestMapping(path = "/testDefaultGetApiExample")
+  public String testDefaultGetApiExample(@RequestBody String name, HttpServletRequest request) {
+    return null;
+  }

Review Comment:
   And I think this test case is wrong. RequestMapping default to GET and it can not have a body parameter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
liubao68 merged PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] codecov-commenter commented on pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#issuecomment-1162902155

   # [Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#3109](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (989f33a) into [master](https://codecov.io/gh/apache/servicecomb-java-chassis/commit/771e7502e0e8a1caf72a1d46913d172b0975853f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (771e750) will **decrease** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3109      +/-   ##
   ============================================
   - Coverage     77.49%   77.49%   -0.01%     
     Complexity     1431     1431              
   ============================================
     Files          1612     1612              
     Lines         43268    43271       +3     
     Branches       3645     3646       +1     
   ============================================
   + Hits          33531    33532       +1     
   - Misses         8235     8236       +1     
   - Partials       1502     1503       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ger/generator/core/AbstractOperationGenerator.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3dhZ2dlci9zd2FnZ2VyLWdlbmVyYXRvci9nZW5lcmF0b3ItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvc3dhZ2dlci9nZW5lcmF0b3IvY29yZS9BYnN0cmFjdE9wZXJhdGlvbkdlbmVyYXRvci5qYXZh) | `88.71% <100.00%> (+0.04%)` | :arrow_up: |
   | [...ation/RequestMappingMethodAnnotationProcessor.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3dhZ2dlci9zd2FnZ2VyLWdlbmVyYXRvci9nZW5lcmF0b3Itc3ByaW5nbXZjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZXJ2aWNlY29tYi9zd2FnZ2VyL2dlbmVyYXRvci9zcHJpbmdtdmMvcHJvY2Vzc29yL2Fubm90YXRpb24vUmVxdWVzdE1hcHBpbmdNZXRob2RBbm5vdGF0aW9uUHJvY2Vzc29yLmphdmE=) | `100.00% <100.00%> (ø)` | |
   | [...agger/generator/core/AbstractSwaggerGenerator.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3dhZ2dlci9zd2FnZ2VyLWdlbmVyYXRvci9nZW5lcmF0b3ItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvc3dhZ2dlci9nZW5lcmF0b3IvY29yZS9BYnN0cmFjdFN3YWdnZXJHZW5lcmF0b3IuamF2YQ==) | `85.03% <0.00%> (-3.15%)` | :arrow_down: |
   | [...mb/config/ConfigCenterConfigurationSourceImpl.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHluYW1pYy1jb25maWcvY29uZmlnLWNjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZXJ2aWNlY29tYi9jb25maWcvQ29uZmlnQ2VudGVyQ29uZmlndXJhdGlvblNvdXJjZUltcGwuamF2YQ==) | `10.86% <0.00%> (+1.08%)` | :arrow_up: |
   | [...ache/servicecomb/foundation/common/net/IpPort.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Zm91bmRhdGlvbnMvZm91bmRhdGlvbi1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NlcnZpY2Vjb21iL2ZvdW5kYXRpb24vY29tbW9uL25ldC9JcFBvcnQuamF2YQ==) | `86.66% <0.00%> (+3.33%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [771e750...989f33a](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3109?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r907484518


##########
demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringMVCSchema.java:
##########
@@ -43,4 +43,16 @@ public class SpringMVCSchema {
   public String testApiExample(@RequestBody String name, HttpServletRequest request) {
     return null;
   }
+
+  @ApiResponses({
+      @ApiResponse(code = 200, response = String.class, message = "success",
+          examples = @Example({
+              @ExampleProperty(value = "wget http://localhost/springMvcSchema/testDefaultGetApiExample", mediaType = "text"),
+              @ExampleProperty(value = "{name:hello}", mediaType = "application/json"),
+              @ExampleProperty(value = "{name:hello}", mediaType = "json")})
+      )})
+  @RequestMapping(path = "/testDefaultGetApiExample")
+  public String testDefaultGetApiExample(@RequestBody String name, HttpServletRequest request) {
+    return null;
+  }

Review Comment:
   Not only schema generation. Should create a server in springmvc-server and a test case in springmvc-client invoke the method. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r904836266


##########
swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/TestSpringmvc.java:
##########
@@ -78,9 +78,8 @@ public void testClassMethodNoPath() {
 
   @Test
   public void testClassMethodNoHttpMetod() {
-    UnitTestSwaggerUtils.testException(
-        "HttpMethod must not both be empty in class and method, method=org.apache.servicecomb.swagger.generator.springmvc.ClassMethodNoHttpMethod:noHttpMethod.",
-        ClassMethodNoHttpMethod.class);
+    UnitTestSwaggerUtils
+        .testSwagger("schemas/requestMappingHttpMethod.yaml", ClassMethodNoHttpMethod.class, "noHttpMethod");

Review Comment:
   write a integration tests in  demo-springmvc



##########
swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/TestSpringmvc.java:
##########
@@ -78,9 +78,8 @@ public void testClassMethodNoPath() {
 
   @Test
   public void testClassMethodNoHttpMetod() {
-    UnitTestSwaggerUtils.testException(
-        "HttpMethod must not both be empty in class and method, method=org.apache.servicecomb.swagger.generator.springmvc.ClassMethodNoHttpMethod:noHttpMethod.",
-        ClassMethodNoHttpMethod.class);
+    UnitTestSwaggerUtils
+        .testSwagger("schemas/requestMappingHttpMethod.yaml", ClassMethodNoHttpMethod.class, "noHttpMethod");

Review Comment:
   write some integration tests in  demo-springmvc



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] zhaozw commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
zhaozw commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r905807092


##########
swagger/swagger-generator/generator-springmvc/src/main/java/org/apache/servicecomb/swagger/generator/springmvc/processor/annotation/RequestMappingMethodAnnotationProcessor.java:
##########
@@ -39,7 +41,9 @@ public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operat
 
     doProcess(operationGenerator,
         requestMapping.path(), requestMapping.value(),
-        requestMapping.method().length == 0 ? null : requestMapping.method()[0],
+        requestMapping.method().length == 0 ?
+            (StringUtils.isEmpty(operationGenerator.getHttpMethod()) ? RequestMethod.GET : null) :

Review Comment:
   take /swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/Echo.java for example:
   class level http method will set to operationGenerator,if method does not have http method,it will use class level http method,so only when both of class level and method level are not set,then we use GET as default.
   
   @RequestMapping(
       path = "Echo",
       method = {RequestMethod.PUT},
       consumes = {"a", "b"},
       produces = {"a", "b"})
   public class Echo {
   
     @RequestMapping
     public void emptyPath() {
     }
   
     @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
     public void multiHttpMethod() {
     }
   
     @RequestMapping
     public void inheritHttpMethod(int query) {
     }
   }



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] zhaozw commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
zhaozw commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r905807092


##########
swagger/swagger-generator/generator-springmvc/src/main/java/org/apache/servicecomb/swagger/generator/springmvc/processor/annotation/RequestMappingMethodAnnotationProcessor.java:
##########
@@ -39,7 +41,9 @@ public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operat
 
     doProcess(operationGenerator,
         requestMapping.path(), requestMapping.value(),
-        requestMapping.method().length == 0 ? null : requestMapping.method()[0],
+        requestMapping.method().length == 0 ?
+            (StringUtils.isEmpty(operationGenerator.getHttpMethod()) ? RequestMethod.GET : null) :

Review Comment:
   take /swagger/swagger-generator/generator-springmvc/src/test/java/org/apache/servicecomb/swagger/generator/springmvc/Echo.java for example:
   class level http method will set to operationGenerator,if method does not have http method,it will use class level http method,so only when both of class level and method level are not set,then we use GET as default.
   ```
   @RequestMapping(
       path = "Echo",
       method = {RequestMethod.PUT},
       consumes = {"a", "b"},
       produces = {"a", "b"})
   public class Echo {
   
     @RequestMapping
     public void emptyPath() {
     }
   
     @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
     public void multiHttpMethod() {
     }
   
     @RequestMapping
     public void inheritHttpMethod(int query) {
     }
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r904837625


##########
swagger/swagger-generator/generator-springmvc/src/main/java/org/apache/servicecomb/swagger/generator/springmvc/processor/annotation/RequestMappingMethodAnnotationProcessor.java:
##########
@@ -39,7 +41,9 @@ public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operat
 
     doProcess(operationGenerator,
         requestMapping.path(), requestMapping.value(),
-        requestMapping.method().length == 0 ? null : requestMapping.method()[0],
+        requestMapping.method().length == 0 ?
+            (StringUtils.isEmpty(operationGenerator.getHttpMethod()) ? RequestMethod.GET : null) :

Review Comment:
   Why use operationGenerator to get method not default to GET? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] zhaozw commented on a diff in pull request #3109: [3108] support @RequestMapping annotation

Posted by GitBox <gi...@apache.org>.
zhaozw commented on code in PR #3109:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3109#discussion_r907947728


##########
demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringMVCSchema.java:
##########
@@ -43,4 +43,16 @@ public class SpringMVCSchema {
   public String testApiExample(@RequestBody String name, HttpServletRequest request) {
     return null;
   }
+
+  @ApiResponses({
+      @ApiResponse(code = 200, response = String.class, message = "success",
+          examples = @Example({
+              @ExampleProperty(value = "wget http://localhost/springMvcSchema/testDefaultGetApiExample", mediaType = "text"),
+              @ExampleProperty(value = "{name:hello}", mediaType = "application/json"),
+              @ExampleProperty(value = "{name:hello}", mediaType = "json")})
+      )})
+  @RequestMapping(path = "/testDefaultGetApiExample")
+  public String testDefaultGetApiExample(@RequestBody String name, HttpServletRequest request) {
+    return null;
+  }

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org