Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 470
Cortlendt Avatar asked Dec 24 '22 08:12

Cortlendt


1 Answers

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)})})
like image 60
Cortlendt Avatar answered Dec 31 '22 08:12

Cortlendt