swagger-ui: Setting default value on an enum causes the default to always be used
| Q | A |
|---|---|
| Bug or feature request? | Bug |
| Which Swagger/OpenAPI version? | 2 |
| Which Swagger-UI version? | 3.2.2 |
| How did you install Swagger-UI? | Composer |
| Which browser & version? | Chrome 61 |
| Which operating system? | Windows 10 |
Whenever a default is set on an enum parameter it becomes impossible to send another version than the default.
Demonstration API definition
swagger: '2.0'
host: localhost
info:
title: Demo
description: Demo
version: 1.0.0
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
'/demo':
get:
summary: Enum demo
parameters:
- name: enum_demo
in: query
required: true
type: string
default: first_value
enum:
- first_value
- second_value
responses:
'200':
description: Result
schema:
type: array
items:
type: object
Expected Behavior
The value selected in the dropdown box to be sent in the query string
Current Behavior
The default value is always sent in the query string
Possible Solution
Whenever you omit the default tag the request is fine
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (11 by maintainers)
I wouldn’t dig too much into it. If the fix is there, it’ll roll into the editor in this week’s release because there’s definitely going to be one.
Yes, this look fine to me. The dropdown selects the default at first, and the right value appears in the query when I submit the request. I tried both with and without the required keyword and with default values that are not in the enum.