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/03/16 11:42:10 UTC

[GitHub] [servicecomb-java-chassis] Leo-Chengguoliang opened a new issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Leo-Chengguoliang opened a new issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635
 
 
   报错信息:
   Cannot construct instance of ‘org.spirngframework.http.ResponseEntity’ (no Creators, like default constructor, ... )
   
   CSE版本:2.3.77.B001
   
   接口定义:
       @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
       @Override
       public ResponseEntity<JSONObject> ping(@RequestHeader(name = HeaderParam.SESSION_ID) String sessionId) {
           transTraceId(0);
   
           ResponseEntity response =
               new ResponseEntity(new Result("open call service is running"), buildResponseHead(sessionId), HttpStatus.OK);
           return response;
       }
   
   自定义的swagger:
     /v2/ping:
       post:
         operationId: "ping"
         produces:
           - "application/json"
         parameters:
           - name: "X-Session-Id"
             in: "header"
             required: true
             type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               type: "object"
               additionalProperties:
                 type: "object"
   另外,不使用自定义swagger文件,使用swagger generator,接口访问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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-600375696
 
 
   这个我在本地试了一把. 启动没问题.. 没复现你的效果.
   
   ```java
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Person> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Person> response =
               new ResponseEntity(new Person(), HttpStatus.OK);
       return response;
     }
   
   ```
   
   **swagger 契约**
   
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               $ref: "#/definitions/Person"
   
   ```
   
   java 如下:
   
   ```
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Object> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Object> response =
               new ResponseEntity(new Object(), HttpStatus.OK);
       return response;
     }
   ```
   swagger 契约
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               type: "object"
   
   ```
   

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-600375696
 
 
   这个我在本地试了一把. 启动没问题.. 没复现你的效果.
   
   ```java
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Person> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Person> response =
               new ResponseEntity(new Person(), HttpStatus.OK);
       return response;
     }
   
   ```
   
   **swagger 契约**
   
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               $ref: "#/definitions/Person"
   
   ```

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-599609614
 
 
   使用 swagger generator 没问题的话, 自己对比下 **swagger generator** 生产的契约和 自定义契约 有啥不一样是不是 就没问题了.

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-600375696
 
 
   这个我在本地试了一把. 启动没问题.. 没复现你的效果.
   
   ```java
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Person> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Person> response =
               new ResponseEntity(new Person(), HttpStatus.OK);
       return response;
     }
   
   ```
   
   **swagger 契约**
   
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               $ref: "#/definitions/Person"
   
   ```
   
   java 如下:
   
   ```
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Object> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Object> response =
               new ResponseEntity(new Person(), HttpStatus.OK);
       return response;
     }
   ```
   swagger 契约
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               type: "object"
   
   ```
   

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-599609614
 
 
   使用 swagger generator 没问题的话, 自己对比下 **swagger generator** 生产的契约和 自定义契约 有啥不一样, 是不是 就没问题了.

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-599857398
 
 
   > 自动生成的Respons都是
   > schema:
   > type: "object"
   > additionalProperties:
   > type: "object"
   > 不容易理解。另外,既然有问题,总要明白哪里有问题,才能不重犯不是?
   
   你是说自动生成的契约和你手写的契约都一样? 但是手写的契约就有问题?
   
   如果是这样的话, 给一个demo 吧. 另外把你手写的契约给一份. 

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-599857398
 
 
   > 自动生成的Respons都是
   > schema:
   > type: "object"
   > additionalProperties:
   > type: "object"
   > 不容易理解。另外,既然有问题,总要明白哪里有问题,才能不重犯不是?
   
   你是说自动生成的契约和你手写的契约都一样? 但是手写的契约就有问题?

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] Leo-Chengguoliang commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
Leo-Chengguoliang commented on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-599836911
 
 
   自动生成的Respons都是
   schema:
               type: "object"
               additionalProperties:
                 type: "object"
   不容易理解。另外,既然有问题,总要明白哪里有问题,才能不重犯不是?

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


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题

Posted by GitBox <gi...@apache.org>.
heyile edited a comment on issue #1635: ConvertCommon转换微服务接口的返回值时失败,使用ConvertSame无此问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1635#issuecomment-600375696
 
 
   这个我在本地试了一把. 启动没问题.. 没复现你的效果, 你手写的契约是不是 **写错了** ...
   
   ```java
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Person> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Person> response =
               new ResponseEntity(new Person(), HttpStatus.OK);
       return response;
     }
   
   ```
   
   **swagger 契约**
   
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               $ref: "#/definitions/Person"
   
   ```
   
   java 如下:
   
   ```
   
     @RequestMapping(value = "/v2/ping", method = RequestMethod.POST, produces = "application/json")
     public ResponseEntity<Object> ping(@RequestHeader(name = "sess") String sessionId) {
   
       ResponseEntity<Object> response =
               new ResponseEntity(new Object(), HttpStatus.OK);
       return response;
     }
   ```
   swagger 契约
   ```
     /v2/ping:
       post:
         operationId: "ping"
         produces:
         - "application/json"
         parameters:
         - name: "sess"
           in: "header"
           required: true
           type: "string"
         responses:
           "200":
             description: "response of 200"
             schema:
               type: "object"
   
   ```
   

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


With regards,
Apache Git Services