I implemented Axum login following one of the example in their repo. Unfortunately, I run into this problem. Can does anyone know whar
At the end, I probably will use axum_session_auth, but did not find the time to test this on. I guess I will have the same problem at the end.
error[E0277]: the trait bound `fn(axum::extract::Path<(u32,)>, axum::extract::Query<__QueryParams__>, axum::extract::State<AppState>, extractors::Json<u32>, axum_login::AuthSession<users::Backend>) -> impl std::future::Future<Output = std::string::String> {__inner__function__}: OperationHandler<_, _>` is not satisfied
--> src/main.rs:120:1
|
120 | / #[api_route(GET "/item/:id?amount&offset&test" with AppState {
121 | | summary: "Get an item",
122 | | description: "Get an item by id",
123 | | id: "get-item",
... |
127 | | responses: { 200: String },
128 | | })]
| |___^ the trait `OperationHandler<_, _>` is not implemented for fn item `fn(axum::extract::Path<(u32,)>, axum::extract::Query<__QueryParams__>, axum::extract::State<AppState>, extractors::Json<u32>, axum_login::AuthSession<users::Backend>) -> impl std::future::Future<Output = std::string::String> {__inner__function__}`
|
note: required by a bound in `get_with`
--> /Users/gradlon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aide-0.13.2/src/axum/routing.rs:345:1
|
345 | method_router_top_level!(get, get_with);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------^
| | |
| | required by a bound in this function
| required by this bound in `get_with`
= note: this error originates in the attribute macro `api_route` which comes from the expansion of the macro `method_router_top_level` (in Nightly builds, run with -Z macro-backtrace for more info)
This is the code used:
#[allow(unused_variables)]
#[api_route(GET "/item/:id?amount&offset&test" with AppState {
summary: "Get an item",
description: "Get an item by id",
id: "get-item",
tags: ["items"],
hidden: false
security: { "auth_session": ["read:items"] },
responses: { 200: String },
})]
async fn item_handler(
id: u32,
amount: Option<u32>,
offset: Option<u32>,
test: Option<u32>,
State(state): State<AppState>,
Json(json): Json<u32>,
auth_session: AuthSession,
) -> String {
"let user = User".to_string()
}
The error is caused by the
OperationHandlernot being implemented for yourAuthSession. You can solve this by usingNoApito wrapAuthSesstionin order to create an empty default documentation.Your code should look something like this:
For more background information check: https://github.com/tamasfe/aide/issues/63