'Unmarshalling query params into object using Swagger/Springfox and Spring Boot
I've got a search endpoint in my REST service. I'm using Spring Boot, so I've got a @RestController setup with a method that returns search results based on a search query. This is the method definition:
@ApiOperation(value = "Get global search results")
@RequestMapping(method = GET, produces = {"application/json"})
public SearchResults get(SearchQuery query) {
...
}
I was hoping that SwaggerUI would show the SearchQuery's fields as separate query params in the ui. It doesn't; it just shows a generic "query" param. If I annotate query with @RequestBody the user can add a json payload to the body, but this is a GET request - I want the user to only use query params.
Any ideas?
Solution 1:[1]
For Srpring 2.6.3 and springdoc 1.6.6 works with @ParameterObject annotation before SearchQuery
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jorge Henrique Sartori Rocha |
