liubao68 commented on issue #2243:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2243#issuecomment-784202090
补充说明下为什么不能使用JsonObject的细节,
这个和具体你使用的库也有关系,以使用io.vertx.core.json.JsonObject为例,代码:
```
@PostMapping(path = "/jsonObject")
public JsonObject jsonObject(@RequestBody JsonObject jsonObject) {
return rpcEndpoint.getJsonObject(jsonObject);
}
```
生成的swagger为:
```
/jsonObject:
post:
operationId: "jsonObject"
parameters:
- in: "body"
name: "jsonObject"
required: true
schema:
$ref: "#/definitions/JsonObject"
responses:
"200":
description: "response of 200"
schema:
$ref: "#/definitions/JsonObject"
definitions:
JsonObject:
type: "object"
properties:
map:
type: "object"
additionalProperties:
type: "object"
empty:
type: "boolean"
x-java-class: "io.vertx.core.json.JsonObject"
```
这个接口用postman请求的时候,需要这样传参:
```
{"map": {"hello":"world"}}
```
即根据swagger来的。 很多时候都不符合用户的理解习惯。 如果需要能够传递map:
```
{"hello":"world"}
```
则需要参考开发指南,扩展JsonObject的解析过程,过程比较麻烦。
参考:https://docs.servicecomb.io/java-chassis/zh_CN/build-provider/interface-constraints/
'REST类型扩展章节'
----------------------------------------------------------------
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:
[email protected]