Why does Swagger selection of enum contains an unwanted empty string option?

Viewed 398

Trying to get rid of the 'empty' value from the enum list on Swagger UI.

Swagger empty value

My field options is a list of enums which null is not a part of it. My OpenApi3 specification is as below:

"description": "number of options", 
"explode": true, 
"in": "query", 
"name": "options", 
"required": false, 
"schema": {
  "items": {
    "enum": [
      1, 
      2, 
      3
    ], 
    "type": "string"
  }, 
  "type": "array"
}, 
"style": "form"

I seem to make it disappear if I make the field required:

enter image description here

But I don't want this. The field should be either nullable or be part of one of the enum values. The reason is that, if the 'empty' value is selected, the request goes like

 http://localhost?options=&...

This brings up a HTTP 400 result with the message

"The value '' is invalid."

I don't want this '--' entry to be listed at all. The field should be nullable (nothing selected) or be part of the enum values.

0 Answers
Related