I am trying to figure out how to make the Swagger UI show a list of allowed values instead of an input field.
So far, I was able to get myself pretty confused with the different versions of Swagger, and the docs. I am not sure which is which (1.2, 2.0, YAML, JSON...)
So far, this is what I know:
- There is some command called
allowableValues
but as far as I understand, its not available in Swagger 2.0 - I found the
enum
command, but was unable to make it work for me. - I am not sure if I should define this list of allowed values in the
parameters
section, ordefinitions
section - I found the petstore example where it does have a select field like I want (GET /pet/findByTags), but as far as I could see in the "raw" JSON, it looks like the older Swagger format.
Finally, here is the code I was trying in this Swagger editor:
swagger: '2.0'
host: asd.com
schemes:
- http
info:
version: "1.0.0"
title: test
paths:
/users:
get:
parameters:
- name: status
in: query
type: string
enum:
- online
- offline
responses:
"200":
description: Nice