Available on crate feature
aide only.Expand description
OpenAPI support through aide, and so through rovo.
With the aide feature the extractors and error types document themselves:
AuthSessionmarks its route as requiring theSECURITY_SCHEMEcookie and documents the layer’s 401 rejections.Option<AuthSession>adds the requirement as well, so a bypass route that also takes an API key lists both as alternatives.Sessionsleaves the route public: it is what login and step-up handlers take.GuardErrorandStepUpErrordocument the responses they convert into.
register adds the scheme itself to the spec; call it once, after finish_api. With rovo,
@security session_cookie on a handler adds the same requirement explicitly.
use aide::{axum::{ApiRouter, routing::get}, openapi::OpenApi};
use session_guard::{AuthSession, Guard, MemoryStore};
use uuid::Uuid;
async fn me(session: AuthSession<Uuid>) -> String {
session.subject.to_string()
}
let guard = Guard::new(MemoryStore::new());
let mut api = OpenApi::default();
let app: axum::Router = ApiRouter::new()
.api_route("/me", get(me))
.with_state(guard.clone())
.finish_api(&mut api);
session_guard::aide::register(&mut api, &guard);Constants§
- SECURITY_
SCHEME - The name of the session cookie’s security scheme:
session_cookie.
Functions§
- register
- Adds
security_schemetoapiasSECURITY_SCHEME. - security_
scheme - The session cookie as an OpenAPI
apiKeyscheme, named after the guard’s cookie.