5

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

{
  "name": "propertyType",
  "in": "query",
  "description": "Type of home",
  "required": false,
  "type": "list",
  "listValues": ["singleFamilyHome", "condo", "farm", …]
}
4

1 回答 1

8

在 swagger 2.0 中,您可以使用枚举:

{
  "name": "propertyType",
  "in": "query",
  "description": "Type of home",
  "required": false,
  "type": "list",
  "enum": ["singleFamilyHome", "condo", "farm"]
}

您可以在此处找到更多信息:如何在 swagger.io 中定义枚举?

于 2015-09-30T15:49:58.193 回答