ResponseHeader annotation not parsed?
See original GitHub issue- What version of the library are you using? 2.9.2
What kind of issue is this?
- Bug report.
Neither of X-Hello
nor X-Hello-Bis
headers are rendered in Swagger-UI from the following controller, while all the other details are correctly displayed:
@CrossOrigin(origins = "*", maxAge = 3600)
@Api(tags={ "Test ResponseHeader" })
@RestController
@RequestMapping(path="/response-header", produces="application/json")
public class ResponseHeaderController {
@ApiResponse(
code=200, message="OK",
responseHeaders={
@ResponseHeader(name="X-Hello-Bis", description="X-Hello-Bis header description", response=String.class)
})
@ApiOperation(
responseHeaders={
@ResponseHeader(name="X-Hello", description="X-Hello header description", response=String.class)
},
value="Get test for response header",
nickname="responseHeader", notes="Notes 'bout test"
)
@GetMapping(path="", produces="text/plain")
public String responseHeader(@ApiParam(hidden=true) HttpServletRequest req, @ApiParam(hidden=true) HttpServletResponse resp) {
resp.addHeader("X-Hello", "Hello!");
resp.addHeader("X-Hello-Bis", "Hallo!");
return "Hi!";
}
}
I found issues #937 and #1271 both closed, am I missing something in my code?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Set response header in Spring Boot - Stack Overflow
There are three ways to do this: Set the response for a specific controller, in the Controller class: @Controller @RequestMapping(value ...
Read more >How to Set a Header on a Response with Spring 5 - Baeldung
In this quick tutorial, we'll explore the different ways of setting a header on a service response, either for non-reactive endpoints or ...
Read more >ApiResponse (swagger-annotations 1.6.2 API) - Javadoc.io
This annotation is not used directly and will not be parsed by Swagger. It should be used within the ... public abstract ResponseHeader[]...
Read more >Web on Servlet Stack - Spring
If an application context hierarchy is not required, applications can ... For example, invoking an annotated controller requires resolving annotations.
Read more >29.2 Creating a RESTful Root Resource Class
The JAX-RS API uses Java programming language annotations to simplify the ... The JAX-RS runtime parses URI path templates the same way, whether...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have just hit this exact problem too, springfox 2.9.2 + spring boot 2.0.5.RELEASE. Tried via both
@ApiResponse
and@ApiOperation
as described above, no response header properties in the generated swagger document.Does this fix apply for SpringFox 3? The description fields in ResponseHeader do not seem to be showing up in swagger.json anymore for me when I bumped the version from 2.9.2 to 3.0.0. I had to replace depreciated methods
ResponseMethodBuilder
->ResponseBuilder
andglobalResponseMessage
->globalResponses
docket configuration