我有一些API会返回以下响应。我怎么能用swagger来做文件呢?我知道swagger responseContainer支持Map,但地图的值类型似乎必须是同一类型。但就我而言,值的类型不同:foos是List的类型,第二个键是" count"对应于整数。
Response.ok(ImmutableMap.of("result", foos, "count", foos.size())).build();
API的响应是这样的:
{
"result": [
{
"f1": "v1",
"f2": "v2"
},
{
"f1": "v3",
"f2": "v4"
}
],
"count": 2
}
答案 0 :(得分:0)
您的回答可以这样描述:
definitions:
MyResponse:
type: object
required:
- result
- count
properties:
result:
type: array
items:
$ref: '#/definitions/Foo'
count:
type: integer
Foo:
type: object
additionalProperties:
type: string