diff --git a/editoast/Cargo.lock b/editoast/Cargo.lock index 18e5d043ade..ae55cdf259a 100644 --- a/editoast/Cargo.lock +++ b/editoast/Cargo.lock @@ -454,9 +454,36 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.4.5", + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "itoa", + "matchit 0.7.3", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.2", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.8.1" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" +dependencies = [ + "axum-core 0.5.0", "axum-macros", "bytes", + "form_urlencoded", "futures-util", "http 1.2.0", "http-body 1.0.1", @@ -464,7 +491,7 @@ dependencies = [ "hyper 1.5.2", "hyper-util", "itoa", - "matchit", + "matchit 0.8.4", "memchr", "mime", "multer", @@ -501,17 +528,36 @@ dependencies = [ "sync_wrapper 1.0.2", "tower-layer", "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" +dependencies = [ + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", "tracing", ] [[package]] name = "axum-extra" -version = "0.9.6" +version = "0.10.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c794b30c904f0a1c2fb7740f7df7f7972dfaa14ef6f57cb6178dc63e5dca2f04" +checksum = "460fc6f625a1f7705c6cf62d0d070794e94668988b1c38111baeec177c715f7b" dependencies = [ - "axum", - "axum-core", + "axum 0.8.1", + "axum-core 0.5.0", "bytes", "futures-util", "headers", @@ -528,9 +574,9 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.4.2" +version = "0.5.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" +checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" dependencies = [ "proc-macro2", "quote", @@ -539,14 +585,14 @@ dependencies = [ [[package]] name = "axum-test" -version = "16.4.1" +version = "17.0.1" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "63e3a443d2608936a02a222da7b746eb412fede7225b3030b64fe9be99eab8dc" +checksum = "53f1009889890a439cbf67a4071a2593d027c65209da4faeac5582f28ca9e6c3" dependencies = [ "anyhow", "assert-json-diff", "auto-future", - "axum", + "axum 0.8.1", "bytes", "bytesize", "cookie", @@ -568,11 +614,11 @@ dependencies = [ [[package]] name = "axum-tracing-opentelemetry" -version = "0.24.1" +version = "0.25.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "04637ce1dedc9d655e5a566ded972e1cc48967282719ea7cd1ef338257cf1d3c" +checksum = "537b722ea45bf47f9fe55c9aac9ca7122e0fea5edb85dced4f6ec411c42fbec5" dependencies = [ - "axum", + "axum 0.8.1", "futures-core", "futures-util", "http 1.2.0", @@ -1239,7 +1285,7 @@ dependencies = [ "anyhow", "async-std", "async-trait", - "axum", + "axum 0.8.1", "axum-extra", "axum-test", "axum-tracing-opentelemetry", @@ -2627,6 +2673,12 @@ version = "0.7.3" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "md-5" version = "0.10.6" @@ -4099,10 +4151,9 @@ dependencies = [ [[package]] name = "serde_qs" version = "0.13.0" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "cd34f36fe4c5ba9654417139a9b3a20d2e1de6012ee678ad14d240c22c78d8d6" +source = "git+/~https://github.com/Atrox/serde_qs?rev=2cfa3ee0#2cfa3ee0af44ad8e78ed6bd6d0e7ac913f51f382" dependencies = [ - "axum", + "axum 0.8.1", "futures 0.3.31", "percent-encoding", "serde", @@ -4653,7 +4704,7 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.7.9", "base64 0.22.1", "bytes", "h2 0.4.7", diff --git a/editoast/Cargo.toml b/editoast/Cargo.toml index d1cae760486..78219fd95b8 100644 --- a/editoast/Cargo.toml +++ b/editoast/Cargo.toml @@ -94,15 +94,15 @@ uuid = { version = "1.11.0", features = ["serde", "v4"] } [dependencies] anyhow = "1.0" async-trait = "0.1.84" -axum = { version = "0.7.9", default-features = false, features = [ +axum = { version = "0.8.1", default-features = false, features = [ "multipart", "tracing", ] } -axum-extra = { version = "0.9.6", default-features = false, features = [ +axum-extra = { version = "0.10.0", default-features = false, features = [ "typed-header", ] } -axum-test = { version = "16.4.1", default-features = false } -axum-tracing-opentelemetry = { version = "0.24.1", default-features = false, features = [ +axum-test = { version = "17.0.1", default-features = false } +axum-tracing-opentelemetry = { version = "0.25.0", default-features = false, features = [ "tracing_level_info", ] } chrono.workspace = true @@ -172,7 +172,11 @@ regex = "1.11.1" reqwest.workspace = true serde = { workspace = true, features = ["derive"] } serde_json.workspace = true -serde_qs = { version = "0.13.0", features = ["axum"] } +# official serde_qs seems unmaintained. Bump to `axum:0.8` is an opened PR waiting to be merged. +# /~https://github.com/samscott89/serde_qs/pull/118 +serde_qs = { version = "0.13.0", git = "/~https://github.com/Atrox/serde_qs", rev = "2cfa3ee0", features = [ + "axum", +] } serde_yaml = "0.9.34" sha1 = "0.10" strum.workspace = true @@ -198,7 +202,7 @@ validator = { version = "0.19.0", features = ["derive"] } [dev-dependencies] async-std = { version = "1.13.0", features = ["attributes", "tokio1"] } -axum = { version = "0.7.9", default-features = false, features = [ +axum = { version = "0.8.1", default-features = false, features = [ "macros", "multipart", "tracing", diff --git a/editoast/src/views/openapi.rs b/editoast/src/views/openapi.rs index 2b802fc1cdc..ab1dc398d24 100644 --- a/editoast/src/views/openapi.rs +++ b/editoast/src/views/openapi.rs @@ -66,24 +66,6 @@ where } } -/// Reformats a service path defined in the OpenApi format to the Axum format -/// -/// For path parameters, the OpenApi format uses curly braces, e.g. `/users/{id}`. -/// The Axum format uses a colon, e.g. `/users/:id`. -/// The `routes!` macro requires path parameters to be defined in the OpenApi format. -pub(in crate::views) fn format_axum_path_parameters(url_with_path_params: &str) -> String { - url_with_path_params - .split('/') - .map(|part| { - if part.starts_with('{') && part.ends_with('}') { - format!(":{}", &part[1..part.len() - 1]) - } else { - part.to_string() - } - }) - .join("/") -} - #[allow(unused)] impl OpenApiPathScope { pub fn new(prefix: Option<&'static str>) -> Self { @@ -227,7 +209,7 @@ macro_rules! routes { (@router [$router:expr] $prefix:literal => {$($tt:tt)+} , $($rest:tt)*) => { $crate::routes!(@router [$router.nest( - &$crate::views::openapi::format_axum_path_parameters($prefix), + &$prefix, $crate::routes!(@router [axum::Router::<$crate::AppState>::new()] $($tt)+) )] $($rest)*