【发布时间】:2016-10-05 13:30:20
【问题描述】:
我正在为一个站点创建一个 API,并且我正在使用 Swagger UI,我目前有一个为用户添加收藏夹的路由,路由是 "/users/{id}/favorites/",规范中的参数是:
"parameters":[
{
"in":"path",
"name":"id",
"description":"User's Id",
"required":true,
"schema":{
"$ref":"#/definitions/User"
}
},
{
"in":"body",
"name":"body",
"description":"Enter user's id and video id for favorite",
"required":true,
"schema":{
"$ref":"#/definitions/Favorite"
}
}
],
规范中收藏夹模型的定义如下所示:
"Favorite":{
"type":"object",
"properties":{
"id":{
"type":"integer",
"format": "int64"
},
"userId":{
"$ref":"#/definitions/User/properties/id"
},
"videoId":{
"$ref":"#/definitions/Video/properties/id"
}
},
"xml":{
"name":"Flag"
}
}
但目前当我走 /api 路线时,显示的 body 参数示例值为
{
"id": 0
}
在文档上,它正确显示了一个几乎正确的请求示例并显示:
{
"id": 0,
"userId": 0,
"videoId": 0
}
如何更改 /api 路由的示例值以显示
{
"userId": 0,
"videoId": 0
}
作为示例,如何从文档中的示例中删除 id 参数
【问题讨论】:
标签: api swagger swagger-ui