I have a controller with method @GET. I would like to pass headers as a Map<String, String>, but a field to pass headers is not visible on swagger UI side.
For example: When I tried to pass header as a @RequestHeader String something - field is visible on swagger UI part, just above place to pass body, but after annotation there is a Map, there is no place to put this headers at all.
public ResponseEntity<MyObject> getObject(
@RequestHeader String test,
@RequestHeader Map<String, String> headers) {
//logic here
}
I would like to be able to pass for example three headers via some textbox (like @RequestBody is working). Not to create countless amount of labels with concrete headers, I would like to pass headers through map via swagger UI. Is it possible?
Thanks
You shouldn't be passing data via request headers like this. Request headers are used to pass information about the client to the server (eg does the client accept gzipped responses)
To pass data to the server you should either use:
Note that GET requests do not support a @RequestBody (standard HTTP protocol, nothing to do with spring / swagger)
Here's an example POST with @PathVariable, @RequestParam and @RequestBody
To invoke this you would POST a JSON body to
/foo/xxx/do-something?test2=yyy
The JSON body would look something like