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 2020/12/14 02:56:40 UTC

[GitHub] [servicecomb-java-chassis] hypggg opened a new issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

hypggg opened a new issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130


   GET 请求里边有List参数怎么办? Get没有requestBody
   这个https://github.com/apache/servicecomb-java-chassis/issues/1737 没办法解决get的问题,
   
   Caused by: java.lang.IllegalStateException: generate swagger operation failed, method=XXXXX
   	at org.apache.servicecomb.swagger.generator.core.AbstractSwaggerGenerator.scanMethods(AbstractSwaggerGenerator.java:301) ~[swagger-generator-core-2.1.1.jar:2.1.1]
   	at org.apache.servicecomb.swagger.generator.core.AbstractSwaggerGenerator.generate(AbstractSwaggerGenerator.java:119) ~[swagger-generator-core-2.1.1.jar:2.1.1]


----------------------------------------------------------------
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.

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



[GitHub] [servicecomb-java-chassis] hypggg commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
hypggg commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744416177


   > 如果是这个场景,在2.1.3版本中,我们是这样用的:
   > 
   > ```java
   > public class SomeAggrParam {
   >   @ApiParam(value = "query lists的描述")
   >   @QueryParam("query_lists")
   >   private List<String> queryLists;
   > 
   >   @ApiParam(value = "header name的描述")
   >   @HeaderParam("header_name")
   >   private String headerName;
   >   
   >   其他参数定义
   > 
   >   getter/setter
   > }
   > 
   > 
   > @RequestMapping(path = "......")
   > public class MyController {
   >   @GetMapping(path = "......")
   >   public String query(@BeanParam SomeAggrParam param) {
   >     return ......;
   >   }
   > }
   > ```
   > 
   > 这里使用的是jax-rs标准中的@BeanParam参数聚合特性
   > 在servicecomb最新版本中,无论是jax-rs,还是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.

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



[GitHub] [servicecomb-java-chassis] hypggg closed issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
hypggg closed issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130


   


----------------------------------------------------------------
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.

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



[GitHub] [servicecomb-java-chassis] hypggg commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
hypggg commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744206957


   好的,试一下


----------------------------------------------------------------
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.

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



[GitHub] [servicecomb-java-chassis] hypggg commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
hypggg commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744199900


   参数有点多,所以就封装了个对象,这是要把这种方法都改成post吗?


----------------------------------------------------------------
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.

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



[GitHub] [servicecomb-java-chassis] hypggg commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
hypggg commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744145346


   我们是定义的对象,对象中包含了List<Integer>,代码如下:
       @RequestMapping(
       		value = "/XXXX", 
       		produces = { "application/json" }, 
       		method = RequestMethod.GET)
       public ResponseEntity<byte[]> exportXXXX(
       		@Valid OpOrderReq opOrderReq) 
       	throws Exception
       {     
   		XXXX;
       }
   
   
   OpOrderReq类包含了这种字段,还有其它基本类型字段
   @Valid
       @JsonProperty("status_array")
       private List<Integer> statusArray = new ArrayList<Integer>();
   
   这种还不是直接传了List<String>类型的参数,这个要怎么改
   


----------------------------------------------------------------
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.

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



[GitHub] [servicecomb-java-chassis] wujimin commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
wujimin commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744140250


   `List<String>`这种是合法的  
   但是`List<User>`这种复杂类型是不可以的,没办法编码,并且这些复杂类型在url上传输,可能还涉及敏感信息泄漏的问题    
     
   如果服务自行评估,不存在信息泄漏,可以尝试使用2.1.3版本中新增加的query参数json编解码功能  
   (增加这个功能仅仅为了兼容某些系统的陈旧接口,没有特殊情况,不建议使用)  
   ```java
     @GetMapping("queryArrJSON")
     public String queryArrJSON(@ApiParam(collectionFormat = "json") @RequestParam("queryArr") String[] queryArr) {
       return Arrays.toString(queryArr) + queryArr.length;
     }
   ```  
   https://github.com/apache/servicecomb-java-chassis/blob/master/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DataTypeSpringmvcSchema.java  
     
   如果还需要其他query codec,可以自行实现自己的QueryCodec 


----------------------------------------------------------------
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.

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



[GitHub] [servicecomb-java-chassis] wujimin commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
wujimin commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744205979


   如果是这个场景,在2.1.3版本中,我们是这样用的:
   ```java
   public class SomeAggrParam {
     @ApiParam(value = "query lists的描述")
     @QueryParam("query_lists")
     private List<String> queryLists;
   
     @ApiParam(value = "header name的描述")
     @HeaderParam("header_name")
     private String headerName;
     
     其他参数定义
   
     getter/setter
   }
   
   
   @RequestMapping(path = "......")
   public class MyController {
     @GetMapping(path = "......")
     public String query(@BeanParam SomeAggrParam param) {
       return ......;
     }
   }
   ```  
   
   这里使用的是jax-rs标准中的@BeanParam参数聚合特性  
   在servicecomb最新版本中,无论是jax-rs,还是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.

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



[GitHub] [servicecomb-java-chassis] wujimin commented on issue #2130: java.lang.IllegalStateException: not allow complex type for query parameter, type=java.util.List.

Posted by GitBox <gi...@apache.org>.
wujimin commented on issue #2130:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2130#issuecomment-744162749


   说实在的,我真的无法理解,为何要这样将对象在url上传递,这是相当不规范的做法……


----------------------------------------------------------------
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.

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