I am writing a swagger definition file for an API. The API is a for a GET request
/path/to/my/api:
get:
summary: My Custom API
description: |
None of these comments really seem to answer the question -- How do you define a SET of items in OpenAPI/Swagger?
A set is essentially an array of unrepeated enum values.
Given possible string values of facebook
, pinterest
, twitter
, a field named share_type
could have values containing one or more of them, ex:
Valid
facebook
twitter
facebook, twitter
facebook, twitter, pinterest
Invalid Items
instagram
facebook, instagram
pinterest, pinterest
Another important distinction is that the values cannot be repeated. This is where the uniqueItems directive can be helpful.
So given the example above, here is what that OpenAPI spec might look like:
share_type:
type: array
enum:
- facebook
- pinterest
- twitter
uniqueItems: true
items: {}