Search code examples
javaspringswaggerspringfox

Springfox: @ResponseHeader in @ApiResponse does not render in Swagger UI


I have Springfox annotations in the code as follows:

    @ApiResponses(value = {
        @ApiResponse(code = 200, message = "Options for the endpoint", responseHeaders = {@ResponseHeader(name = "Allow", description = "Verbs allowed")})})

However, the header is not being rendered below the response In Swagger UI.

If I add global response (for internal server error) through Docket, its header renders just fine.

enter image description here

Is this a misconfiguration or what is a problem here?


Solution

  • My problem was that annotation parameter "response" was not set to String.class. It defaults to Void.class and does not render with it.

    Corrected code is:

    @ApiResponse(code = 200, message = "Options for the endpoint", responseHeaders = {@ResponseHeader(name = "Allow", description = "Verbs allowed", response = String.class)})})