-
Notifications
You must be signed in to change notification settings - Fork 11
Support for response header documentation #181
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
Comments
I suppose one way would be to wrap the response in a wrapper type and manually implement Responder and ApiComponent, without using the derive macro as well. That doesn't seem like a good intended way though for just supporting more options in the response documentation. |
Hey, thanks for the report. There is currently no acceptable way to document a response header, I will have a look at it. |
I see two possibilities here:
The second one would allow to document response when the handler return an WDYT ? |
My thoughts on the syntax went into a similar direction. Though I see a pattern here. The I think introducing all of these fields under a response field would make the api cleaner and would allow for even more future expansion in case people would like to document other response related things. For example cookies? (which also aligns pretty tight with this issue, just to keep it close mentally). Maybe there's even more things that a response would turn opaque, and there's no proper way to make these all known since an HttpResponse object is extremely flexible and we can't inspect it later on runtime. One extremely cursed thing that'd also be possible is to introspection the full path of any function ident in the proc macro, and extract the arguments, including any header names. But I can see how that doesn't hold stably in any way and completely disregards non-static variables passed into header insertion functions. TLDR; I'd go with a response attribute and move response related things in there, as well as expand it in the future. |
The OpenAPI Spec includes the possibility to provide information about (custom) headers passed through the responder of a handler, in actix_web usually that resolved to a HttpResponse(Builder) object. This is probably analogous to a feature on the #[api_operation] macro.
Currently there's the use case where you would like to document information about custom headers passed in the response, and I don't see the possibility to do this in any way.
The text was updated successfully, but these errors were encountered: