2

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?

2 Answers 2

3

For Srpring 2.6.3 and springdoc 1.6.6 works with @ParameterObject annotation before SearchQuery

Sign up to request clarification or add additional context in comments.

Comments

2

Annotate SearchQuery with @ModelAttribute and it should work as expected.

2 Comments

Well, that was easy. Very nice. Thanks, brother.
It does not work for me with Srpring 2.6.3 and springdoc 1.6.6...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.