Search code examples
swaggeropenapiswagger-2.0

Defining enum for array in Swagger 2.0


type": "array",
"items": {
    "type": "string",
    "enum": ["MALE","FEMALE","WORKER"]
}

or

type": "array",
"items": {
    "type": "string",
},
"enum": ["MALE","FEMALE","WORKER"]

?

Nothing in the spec about this. The goal is of course to get swagger-ui to show the enum values.


Solution

  • The first case is correct and these days swagger-ui generates a multiple-choise select of the enum values.

    enter image description here