New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response headers not being displayed in UI #655
Comments
Unfortunately the swagger editor and swagger ui are separate products. According to the devs doing swagger-ui - some of the editor features might get implemented into swagger-ui. This is, unfortunately not a swashbuckle issue :) |
@VisualBean is correct. If there's not a similar issue logged already, you should submit this here: https://github.com/swagger-api/swagger-ui |
Thanks venerik! I updated this to work with Swashbuckle 6.0. Note the attribute name change to match the way 6.0 uses ProducesResponseType instead of SwaggerResponse and ints to describe the status code. Attribute:
Filter:
Controller:
|
FWIW @venerik's code above seems to work fine 2 years later, with Swashbuckle 5.6.0. I'm currently adding this functionality to my existing NuGet packages, for those too lazy to copy and paste code. https://www.nuget.org/packages/Swashbuckle.Examples/ |
Just a small recommendation, the GetCustomAttributes has been depreciated and the code should now look like this:
|
Small tweak to @rocklan 's response to accommodate 5.0.0-rc5 (and the shift to OpenApi): public class AddResponseHeadersFilter : IOperationFilter
} |
@WhitWaldo yep, I ported it to OpenApi almost a year ago. Or you can get it from my NuGet (Swashbuckle.AspNetCore.Filters). |
I wrote a custom
SwaggerResponseHeader
attribute to document response headers. I also wrote a customAddResponseHeadersFilter
to add the documentation to the swagger output. I then used the attribute on one of the controller actions. All works fine. The swagger output contains the specified response header and the editor at editor.swagger.io nicely displays the response header.My API's swagger UI however does not display the response header. Is there a way to fix that?
Attribute
Filter
Controller
Documentation (part)
The text was updated successfully, but these errors were encountered: