Examples for enum Choices
When using the Swagger Editor, and specifying a set of choices for a parameter with enum, it is not possible to specify examples for each enum value. While this kind of situation my not frequently arise, it has occurred in the REST API that I am currently documenting. In this API, it is possible to pass either an email address or a user key as a URL parameter to retrieve information on a particular user. The syntax for the call would be as follows:
curl -X GET "https://dev.test.com/xapis/User/first_key" -H "accept: application/json"
where first_key might be either an email address or a user key.
It is possible to document this kind of syntax in the Swagger Editor, as follows:
'/fsfd/User/{first_key}': get: tags: - User summary: Retrieve information on a user. description: 'Use GET to retrieve information on a user. To do this, specify the user key immediately after /xapis/User/.' parameters: - name: first_key in: path description: A user key must be specified when you use GET. required: true style: simple explode: false schema: enum: - user_key - email_address type: string
It is possible to select either user_key or email_address on the drop down, as shown in the screen shot, but it is not possible to specify an example to be inserted when either user_key or email_address is selected on Swagger Inspector and a user tries out the syntax.
Is there any way - perhaps outside of Swagger Editor itself - to specify examples for enum values?
Thanks!
Kevin
No, there's no way to describe mutually exclusive parameters.