Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parameter selection dropdown selects a default value on the UI from allowableValues even if defaultValue is not set but cannot be Executed with that value #3890

Closed
142Old2 opened this issue Nov 10, 2017 · 6 comments

Comments

@142Old2
Copy link

142Old2 commented Nov 10, 2017

Bug

Swagger version:
Maven io.swagger/swagger-jersey2-jaxrs 1.5.13

Swagger-UI version:
3.0.7/g69fd57f-dirty

Chrome Version 55.0.2883.87 m

Widnows 7 Professional

Code that causes the issue

@ApiParam(required = true, allowableValues = "TYPE1, TYPE2, TYPE3, TYPE4", value = "Update what Type of data") @PathParam(value="dataType") final String dataType,

Expected Behavior

A parameter with allowableValue set but no defaultValue should either not show a selected value in the dropdown box until explicitly selected by the user, or should show a default value (first in the list, for example) that is functional and allows the user to click Execute and send the request.

Current Behavior

Currently, dropdowns for parameters with allowableValue set but no defaultValue will show the first allowable value in the field by default. However, that apparent value shown on the web UI is not actually properly selected, and clicking Execute will silently fail to send any request or perform any action, without feedback to the user. To actually send a request, the user must click to open the dropdown and manually select an option. The need to manually select a value is hidden by the presence of an apparently already-selected default option.

Possible Solution

Either:

  • A parameter with allowableValue set but no defaultValue should not show a default value for the dropdown box at all OR
  • If a value must be shown for the dropdown box even if no defaultValue is set, it should function properly and allow the user to send the request without manually opening the box and selecting a value

Context

This is quite misleading to users, since an apparent default value for the parameter is selected but is not functional. The user must manually set a value for the dropdown for it to work, but the display of the field itself suggests that a default value is already selected.

@shockey
Copy link
Contributor

shockey commented Nov 10, 2017

Hi @gdavidmac, sorry you're having issues.

I'm a bit confused by your report - here's some clarifying questions:

  • What is an allowableValue? Are you referring to parameter enums?
  • Are you using Swagger 2.0 or OpenAPI 3.0?

Regarding your Code that causes the issue - the code you shared isn't really helpful, very few people on this project use Java. Please share a Swagger or OpenAPI definition that we can use to reproduce the issue.

@hkosova
Copy link
Contributor

hkosova commented Nov 10, 2017

@gdavidmac, try the latest version of Swagger UI.

@shockey this sounds like one of the enum try-it-out bugs that were fixed in previous updates.

@142Old2
Copy link
Author

142Old2 commented Nov 10, 2017

Hi @shockey

Sorry, I didn't realize the Java version was not in common use, I'll try to restate my question using more correct Swagger terminology.

  • Correct, when I write allowableValues that is referring to parameter enums
  • Swagger version is 1.5.13 (seems old, this might be our problem)
  • Relevant Swagger definition (obfuscated slightly) is:
"put": {
		"tags": ["{OBFUSCATED}"],
		"summary": "Update data",
		"description": "Update data",
		"operationId": "createOrUpdateWithId",
		"consumes": ["application/json"],
		"produces": ["application/json"],
		"parameters": [
			...etc...
			, {
				"name": "dataType",
				"in": "path",
				"description": "Update what Type of data",
				"required": true,
				"type": "string",
				"enum": ["TYPE1", "TYPE2", "TYPE3", "TYPE4"]
			}
...etc

I think @hkosova is correct that this looks very similar to the linked bugs regarding default values for enum parameters, where a default selected value appears for the dropdown box on the UI, but that default selected value does not work. Are those fixes included in a subsequent Swagger-UI version?

@shockey
Copy link
Contributor

shockey commented Nov 10, 2017

@gdavidmac:

Sorry, I didn't realize the Java version was not in common use

No worries. It is pretty common downstream of us (lots of Java Swagger tooling ships with Swagger-UI) but I only speak Swagger/OpenAPI and JavaScript 😄

Swagger version is 1.5.13 (seems old, this might be our problem)

Hmm, that's not a valid Swagger version 😕 You might be looking at the version of your tool - do you have a swagger or openapi property at the top level of your API definition? FWIW, if Swagger-UI 3.x is displaying your definition at all, you're either using Swagger 2.0 or OpenAPI 3.0. Lots of numbers here, sorry! There's many pieces to the Swagger puzzle.

Valid Swagger versions are 1.0, 1.1, 1.2, and 2.0, while OpenAPI currently only has 3.0.0.

Are those fixes included in a subsequent Swagger-UI version?

Yes, it is. You should try opening your definition at http://petstore.swagger.io/ (or use http://editor.swagger.io if you'd prefer to copy-paste your definition instead of loading via HTTP request), both of those pages are kept up-to-date with the latest version of Swagger-UI (current 3.4.3).

If you still see the issue there, then we have a bug on our hands.

@webron
Copy link
Contributor

webron commented Nov 13, 2017

@gdavidmac @shockey swagger-core 1.5.13 is not that far behind the latest version and the definition itself looks correct. It's outputting Swagger 2.0 definitions.

@gdavidmac please just try with the latest version to see if the issue is resolved.

@shockey
Copy link
Contributor

shockey commented Nov 20, 2017

Closing due to inactivity.

This is simply to keep our issue tracker clean - feel free to comment if there are any further thoughts or concerns, and we'll be happy to reopen this issue.

@shockey shockey closed this as completed Nov 20, 2017
@lock lock bot locked and limited conversation to collaborators Jul 2, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

4 participants