Brad
Brad

Reputation: 163538

List of possible values for API query parameter in Swagger

When documenting an API, is there a way to provide a list of possible values? Something like this:

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

Upvotes: 5

Views: 9979

Answers (1)

David Lopez
David Lopez

Reputation: 2257

In swagger 2.0 you can use enum:

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

You ca find more info here: How to define enum in swagger.io?

Upvotes: 8

Related Questions