Why Doesn't Swagger UI Display Enum Dropdown for Query Parameters?
Problem
When I configure allowableValues in my Swagger annotations, I expect Swagger UI to show a dropdown list of allowed values. But instead, I get only a plain text input field with no indication of valid options.
Here’s what I see in Swagger UI:
poi_types: [text input field - no dropdown]But my swagger.json clearly has the enum values:
{ "name": "poi_types", "in": "query", "description": "Types of locations to include", "required": false, "type": "string", "enum": ["pos", "wifi", "country"]}Environment
- Spring Boot with JAX-RS
- Maven project
- swagger-core 1.5.20 (also tested with 1.6.2)
- Swagger annotations (
@ApiImplicitParam,@ApiParam) - Tested in Firefox and Chrome
What happened?
I wanted to restrict a query parameter to specific values and have Swagger UI display these as selectable options. I added allowableValues to my annotation:
@GET@Path("/locations")@ApiOperation("Get locations by type")@ApiImplicitParams({ @ApiImplicitParam( name = "poi_types", value = "Types of locations to include", allowableValues = "pos, wifi, country", dataType = "string", paramType = "query" )})public Response getLocations(@QueryParam("poi_types") String poiTypes) { // implementation}I verified that swagger.json was generated correctly with the enum array. But when I opened Swagger UI, I saw a plain text input field instead of a dropdown.
I tried upgrading swagger-core from 1.5.20 to 1.6.2 - no change.
I also tried using @ApiParam instead of @ApiImplicitParam:
@GET@Path("/countries")public Response getCountries( @QueryParam("isocc2") @ApiParam( name = "isocc2", value = "Country code", allowableValues = "en, es" ) String countryCode) { // implementation}Same result - enum in swagger.json, but no dropdown in Swagger UI.
Why this happens?
I think there are several potential causes:
-
Swagger UI version mismatch - The swagger-core library version controls spec generation, but Swagger UI is a separate component. Spring Boot may bundle an older UI version that doesn’t properly render enums for query parameters.
-
OpenAPI 2.0 vs 3.0 format - Swagger 2.0 (OpenAPI 2.0) uses a different parameter structure than OpenAPI 3.0:
"name": "status","in": "query","type": "string","enum": ["active", "inactive", "pending"]"name": "status","in": "query","schema": { "type": "string", "enum": ["active", "inactive", "pending"]}Newer Swagger UI versions (3.x+) may expect the OpenAPI 3.0 format with the schema wrapper.
- Browser caching - The browser might cache an older swagger.json or UI assets.
How to diagnose it?
I recommend checking these things:
-
Verify Swagger UI version - Open browser dev tools and look for the version in loaded JavaScript or HTML footer.
-
Check swagger.json loading - Use the Network tab in dev tools to confirm the correct swagger.json is being loaded.
-
Clear browser cache - Hard refresh with Ctrl+Shift+R (or Cmd+Shift+R on Mac).
-
Test standalone Swagger UI - Try serving your swagger.json to a standalone swagger-ui-dist instance to compare rendering.
-
Check framework integration - Spring Boot swagger starters may bundle specific UI versions.
What can you try?
If swagger.json is correct but UI doesn’t render dropdowns:
-
Upgrade Swagger UI separately - Don’t assume upgrading swagger-core affects the UI.
-
Consider OpenAPI 3.0 migration - Use
springdoc-openapiinstead of older swagger libraries for better UI compatibility. -
Use standalone Swagger UI - Download swagger-ui-dist and serve your swagger.json directly.
Summary
In this post, I explained why Swagger UI may not display enum dropdowns even with correct swagger.json. The key point is that swagger-core and Swagger UI are separate - upgrading swagger-core doesn’t upgrade the UI. Check your actual Swagger UI version, consider OpenAPI 3.0 migration, and test with standalone UI to isolate the issue.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments