liubao68 commented on issue #4303:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/4303#issuecomment-2071280339
感觉这个场景违背了一些基础的设计,无法保证兼容。
1. 使用Java
Chassis,一个状态码,只能存在一个类型的响应,但是可以有不同的content-type,具体content-type是由java
chassis决定的(支持的类型由已经实现的功能决定)。比如:状态码200,
返回String,content-type支持json、text、protobuffer。 使用 OpenAPI表示为:
```
responses:
"200":
description: response of 200
content:
application/json:
schema:
type: string
application/protobuf:
schema:
type: string
text/plain:
schema:
type: string
```
Java
Chassis不支持一个状态码多种返回值类型(schema),OpenAPI也不支持(理论上,OpenAPI一个状态的不同content-type可以使用不同的类型,但是这个在实现上是和java
chassis的实现方式违背的,协议规范并没考虑到实现方式,不够成协议约束)。
2. 多种类型响应的时候,需要使用不同的2xx错误码,比如200, 201, 202等。 异常情况,使用4xx,5xx表示。
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]