-
After upgrading to aide 0.14 with axum 0.8, a route using axum's
Switching to Query of axum-extra works. How to reproduceThe following compiles, remove the comment to trigger the bug. use aide::{
axum::{routing::get, ApiRouter, IntoApiResponse},
openapi::{Info, OpenApi},
};
use axum::{extract::Query, Extension, Json};
use axum_extra::extract::Query as ExtraQuery;
use schemars::JsonSchema;
use serde::Deserialize;
use tokio::net::TcpListener;
#[derive(Deserialize, JsonSchema)]
struct Example {
value: usize,
}
async fn axum(Query(query): Query<Example>) -> impl IntoApiResponse {
query.value.to_string()
}
async fn axum_extra(ExtraQuery(query): ExtraQuery<Example>) -> impl IntoApiResponse {
query.value.to_string()
}
async fn serve_api(Extension(api): Extension<OpenApi>) -> impl IntoApiResponse {
Json(api)
}
#[tokio::main]
async fn main() {
aide::generate::on_error(|error| {
println!("{error}");
});
aide::generate::extract_schemas(true);
let mut api = OpenApi {
info: Info {
description: Some("an example API".to_string()),
..Info::default()
},
..OpenApi::default()
};
let app = ApiRouter::new()
// uncomment following line to trigger bug
//.api_route("/axum", get(axum))
.api_route("/axum_extra", get(axum_extra))
.route("/api.json", get(serve_api));
let listener = TcpListener::bind("0.0.0.0:4000").await.unwrap();
axum::serve(
listener,
app.finish_api(&mut api)
.layer(Extension(api))
.into_make_service(),
)
.await
.unwrap();
} [package]
name = "aide_reproduce"
version = "0.1.0"
edition = "2021"
[dependencies]
aide = { version = "0.14.0", features = ["axum", "macros", "axum-json", "axum-extra-query"]}
axum = { version = "0.8.1" , features = ["query", "json", "macros"]}
axum-extra = { version = "0.10.0", features = ["query"]}
schemars = "0.8.21"
serde = { version = "1.0.217", features = ["derive"]}
tokio = { version = "1.43.0", features = ["rt-multi-thread"]} Obeservation:When you remove |
Beta Was this translation helpful? Give feedback.
Answered by
jplatte
Jan 23, 2025
Replies: 1 comment 4 replies
-
aide's Cargo features are more fine-grained in 0.14.0, was the |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
mguentner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aide's Cargo features are more fine-grained in 0.14.0, was the
axum-query
feature enabled when you first tried this?