| 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.
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
The value selected in the dropdown box to be sent in the query string
The default value is always sent in the query string
Whenever you omit the default tag the request is fine
This spec is probably not valid.
1) If enum is used, the default value should be part of that enum.
2) More importantly, default is not used with required parameters. It's an attribute of optional parameters and is handled on the server side. That is, if the client does not supply the parameter, the server will use the default value.
@webron?
As for 1, you are right and in my actual implementation the default is actually part of the enum. I edited my example, but it doesn't matter for the results.
The Swagger editor does not indicate there is an error in the specification, but even so: if the default is to be handled on the server the interface should not put the default value in the query string if I select a different one.
@BasKooij - having default and required for the same property/parameter is indeed pointless, however, it doesn't contradict the spec which is why the editor doesn't throw an error. We should provide a warning though, and I'll file a separate ticket for that.
@owenconti - this is a fairly critical bug. If you can't work on it for this week's release, please let @shockey know so he can take over.
Not sure if I am missing something, but I cannot reproduce the issue with the provided spec in the OP. See screenshot:

Please advise @webron and @BasKooij
Nevermind. I cannot reproduce on petstore.swagger.io, but I can on editor.swagger.io
Okay, further confusion here:
swagger-uiswagger-editorswagger-ui to swagger-editor so I was using master both of the cloned reposswagger-editor instance eitherI did notice though, that the versions information is different across the various environments:



@shockey Do you have any ideas on how I should be trying to fix this?
@owenconti, I’ll take a look, and try to reproduce this on my end.
@owenconti keep in mind the online editor uses one version back of swagger-ui as there was no release last Friday - and swagger-ui had a bunch of fixes in it. Maybe the issue was there and is no longer?
That would explain all the symptoms I was seeing then!
On Wed, Oct 4, 2017 at 7:36 PM Ron notifications@github.com wrote:
@owenconti https://github.com/owenconti keep in mind the online editor
uses one version back of swagger-ui as there was no release last Friday -
and swagger-ui had a bunch of fixes in it. Maybe the issue was there and is
no longer?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/swagger-api/swagger-ui/issues/3726#issuecomment-334335504,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAwStrycESwOINI1GwO3KoRT2NYiqC4Hks5spDKtgaJpZM4PsOad
.
Yep, looks like [email protected] has this issue, but [email protected] does not.
I'm looking for a specific commit that fixes it now.
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.
Hi @BasKooij, now that swagger-editor has been updated, could you please confirm this has been fixed on http://editor.swagger.io?
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.
The issue seems back on 3.17.3 (editor.swagger.io as of 2018-07-17)
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
enum:
- first_value
- second_value
responses:
'200':
description: Result
schema:
type: array
items:
type: object
Shows the issue.
Ah, it's this issue: https://github.com/swagger-api/swagger-ui/issues/4693 already fixed.
Most helpful comment
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.