Annotating Spring Controller's query params with @RequestParam Map<String,String> is sending wrong request from Swagger UI
See original GitHub issueSpringFox version: 2.8.0 SpringFox modules: springfox-swagger2, springfox-swagger-ui lib/springfox-swagger-common-2.8.0.jar lib/springfox-swagger-ui-2.8.0.jar lib/springfox-swagger2-2.8.0.jar lib/swagger-annotations-1.5.14.jar lib/swagger-models-1.5.14.jar
Referencing issue - #2279
Code:
I have annotated the Contoller method with the following annotation
@RequestMapping(value = "/search", method = RequestMethod.GET)
@ApiOperation(value = "Search based on the search term", response = SearchResult.class)
public SearchResult search(
@ApiParam(name="allParams", value="All Params for the search request")
@RequestParam Map<String,String> allParams) {
//doSomething with the query params
}
This shows up like this in Swagger UI
allParams
[object]
(query)
I specify a value for the allParams as below
{ "searchTerm" : "cnn" }
Expected output:
(This is how spring expects the input to be where all the query parameters are mapped as key value pairs in a java.util.Map) http://localhost:8090/search?searchTerm=cnn
Actual output from Swagger UI:
Swagger UI is generating a URL like the one below (the curl command in UI) http://localhost:8090/search?allParams={ "searchTerm" %3A "cnn" }
Question:
How to handle Map<String,String> for request parameters when using SpringFox ??
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
input name=stefan
Expected curl http://localhost:8080/scan?name=stefan Actual curl http://localhost:8080/scan?search=name=stefan
It’s prepending variable name and = before actual input. Doesn’t work in 2.9.2 still or I am doing something wrong.
These functions throw
new UnsupportedOperationException()
…