Skip to content

Commit 21bf477

Browse files
authored
[Rust] Bump axum and axum-extra (#20548)
* Bump axum and axum-extra to latest version. - This bump requires fixing path parameters due to matchit transitive dependency changes (See tokio-rs/axum#2645). - The `Host` extractor has been moved from `axum` to `axum-extra`. - Axum now ships multipart extractor support, switch to that. * Update rust-axum samples
1 parent aeb7caf commit 21bf477

File tree

58 files changed

+104
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+104
-104
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
427427
for (CodegenParameter param : op.pathParams) {
428428
// Replace {baseName} with {paramName} for format string
429429
String paramSearch = "{" + param.baseName + "}";
430-
String paramReplace = ":" + param.paramName;
430+
String paramReplace = "{" + param.paramName + "}";
431431

432432
axumPath = axumPath.replace(paramSearch, paramReplace);
433433
}

modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ conversion = [
4040

4141
[dependencies]
4242
async-trait = "0.1"
43-
axum = "0.7"
44-
axum-extra = { version = "0.9", features = ["cookie", "multipart"] }
43+
axum = { version = "0.8", features = ["multipart"] }
44+
axum-extra = { version = "0.10", features = ["cookie"] }
4545
base64 = "0.22"
4646
bytes = "1"
4747
chrono = { version = "0.4", features = ["serde"] }

modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
3737
async fn handle_error(
3838
&self,
3939
method: &::http::Method,
40-
host: &axum::extract::Host,
40+
host: &axum_extra::extract::Host,
4141
cookies: &axum_extra::extract::CookieJar,
4242
error: E
4343
) -> Result<axum::response::Response, http::StatusCode> {
@@ -47,4 +47,4 @@ pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
4747
.body(axum::body::Body::empty())
4848
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)
4949
}
50-
}
50+
}

modules/openapi-generator/src/main/resources/rust-axum/apis.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_trait::async_trait;
22
use axum::extract::*;
3-
use axum_extra::extract::{CookieJar, Multipart};
3+
use axum_extra::extract::{CookieJar, Host};
44
use bytes::Bytes;
55
use http::Method;
66
use serde::{Deserialize, Serialize};

modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22

33
use axum::{body::Body, extract::*, response::Response, routing::*};
4-
use axum_extra::extract::{CookieJar, Multipart};
4+
use axum_extra::extract::{CookieJar, Host};
55
use bytes::Bytes;
66
use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
77
use tracing::error;

samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ conversion = [
1818

1919
[dependencies]
2020
async-trait = "0.1"
21-
axum = "0.7"
22-
axum-extra = { version = "0.9", features = ["cookie", "multipart"] }
21+
axum = { version = "0.8", features = ["multipart"] }
22+
axum-extra = { version = "0.10", features = ["cookie"] }
2323
base64 = "0.22"
2424
bytes = "1"
2525
chrono = { version = "0.4", features = ["serde"] }

samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
3333
async fn handle_error(
3434
&self,
3535
method: &::http::Method,
36-
host: &axum::extract::Host,
36+
host: &axum_extra::extract::Host,
3737
cookies: &axum_extra::extract::CookieJar,
3838
error: E,
3939
) -> Result<axum::response::Response, http::StatusCode> {

samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_trait::async_trait;
22
use axum::extract::*;
3-
use axum_extra::extract::{CookieJar, Multipart};
3+
use axum_extra::extract::{CookieJar, Host};
44
use bytes::Bytes;
55
use http::Method;
66
use serde::{Deserialize, Serialize};

samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22

33
use axum::{body::Body, extract::*, response::Response, routing::*};
4-
use axum_extra::extract::{CookieJar, Multipart};
4+
use axum_extra::extract::{CookieJar, Host};
55
use bytes::Bytes;
66
use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
77
use tracing::error;
@@ -32,7 +32,7 @@ where
3232
get(get_payment_methods::<I, A, E, C>),
3333
)
3434
.route(
35-
"/v71/paymentMethods/:id",
35+
"/v71/paymentMethods/{id}",
3636
get(get_payment_method_by_id::<I, A, E, C>),
3737
)
3838
.route("/v71/payments", post(post_make_payment::<I, A, E, C>))

samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ conversion = [
1818

1919
[dependencies]
2020
async-trait = "0.1"
21-
axum = "0.7"
22-
axum-extra = { version = "0.9", features = ["cookie", "multipart"] }
21+
axum = { version = "0.8", features = ["multipart"] }
22+
axum-extra = { version = "0.10", features = ["cookie"] }
2323
base64 = "0.22"
2424
bytes = "1"
2525
chrono = { version = "0.4", features = ["serde"] }

0 commit comments

Comments
 (0)