Swagger中API查询参数的可能值列表

Bra*_*rad 5 swagger swagger-2.0

记录API时,有没有办法提供可能的值列表?像这样的东西:

{
  "name": "propertyType",
  "in": "query",
  "description": "Type of home",
  "required": false,
  "type": "list",
  "listValues": ["singleFamilyHome", "condo", "farm", …]
}
Run Code Online (Sandbox Code Playgroud)

小智 8

在swagger 2.0中你可以使用枚举:

{
  "name": "propertyType",
  "in": "query",
  "description": "Type of home",
  "required": false,
  "type": "list",
  "enum": ["singleFamilyHome", "condo", "farm"]
}
Run Code Online (Sandbox Code Playgroud)

你可以在这里找到更多信息:如何在swagger.io中定义枚举?