Using aide in an axum app that also utilizes tower_sessions::Session #192
Replies: 1 comment 3 replies
-
aide only sees the parameter and the return types of your handlers, nothing else. If you have a
I'd say that this is the way to do it, so that everyone, including aide immediately sees what the handler needs.
By itself the derive macro only generates an empty implementation so that the type can be used in handlers but you need to manually implement |
Beta Was this translation helpful? Give feedback.
-
I apologize if this question is somewhat vague; it comes from the fact that I'm not sure if I'm on the right path.
I'm designing an axum app that will be interacted with by a web front-end and a mobile app. Because of this, I want strong openapi docs to help the implementation of the client side. So far, aide has been great. I also want to implement session handling so that some data can be persisted between calls. For this, I have implemented a middleware to insert a session object into the request extensions.
The problem comes in now where because I have to consume request to get to the session object, I now need to parse the body in my function to resolve the inbound json payload for POSTs. This seems to break how aide handles detecting inputs/outputs, even if I derive
OperationIo
and use#[aide(input)]
, etc.I've been looking for the 'right way' to hint to aide what the proper inputs and outputs are for the routes, but now I'm wondering if I'm even going about this the right way. Some other axum-derived projects instead create a new struct that implements
FromRequest
andFromRequestParts
, and I'm wondering whether I should be doing something like that.I guess the TL;DR boils down to: "does anyone have a small example of how to use aide for documenting routes while also using tower_sessions Session management?"
Beta Was this translation helpful? Give feedback.
All reactions