Skip to content

Commit 80be730

Browse files
authored
[Rust-Axum] Adapt changes upon Host extractor sunset (#22585)
* [Rust-Axum] Adapt changes upon Host extractor sunset * Update
1 parent 19945d9 commit 80be730

93 files changed

Lines changed: 583 additions & 285 deletions

File tree

Some content is hidden

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

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ conversion = [
4242
ammonia = "4"
4343
async-trait = "0.1"
4444
axum = { version = "0.8", features = ["multipart"] }
45-
axum-extra = { version = "0.12", features = ["cookie", "query"] }
45+
axum-extra = { version = "0.12", features = [
46+
"cookie",
47+
"query",
48+
"typed-header",
49+
] }
4650
base64 = "0.22"
4751
bytes = "1"
4852
chrono = { version = "0.4", features = ["serde"] }
@@ -51,6 +55,7 @@ frunk-enum-core = { version = "0.3", optional = true }
5155
frunk-enum-derive = { version = "0.3", optional = true }
5256
frunk_core = { version = "0.4", optional = true }
5357
frunk_derives = { version = "0.4", optional = true }
58+
headers = "0.4"
5459
http = "1"
5560
lazy_static = "1"
5661
regex = "1"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
9191
async fn handle_error(
9292
&self,
9393
method: &::http::Method,
94-
host: &axum_extra::extract::Host,
94+
host: &headers::Host,
9595
cookies: &axum_extra::extract::CookieJar,
9696
error: E
9797
) -> Result<axum::response::Response, http::StatusCode> {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use async_trait::async_trait;
22
use axum::extract::*;
3-
use axum_extra::extract::{CookieJar, Host};
3+
use axum_extra::extract::CookieJar;
44
use bytes::Bytes;
5+
use headers::Host;
56
use http::Method;
67
use serde::{Deserialize, Serialize};
78

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

33
use axum::{body::Body, extract::*, response::Response, routing::*};
4-
use axum_extra::extract::{CookieJar, Host, Query as QueryExtra};
4+
use axum_extra::{
5+
TypedHeader,
6+
extract::{CookieJar, Query as QueryExtra},
7+
};
58
use bytes::Bytes;
6-
use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
9+
use headers::Host;
10+
use http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header::CONTENT_TYPE};
711
use tracing::error;
812
use validator::{Validate, ValidationErrors};
913

10-
use crate::{header, types::*};
11-
1214
#[allow(unused_imports)]
1315
use crate::{apis, models};
14-
16+
use crate::{header, types::*};
1517
#[allow(unused_imports)]
16-
use crate::{models::check_xss_string, models::check_xss_vec_string, models::check_xss_map_string, models::check_xss_map_nested, models::check_xss_map};
18+
use crate::{
19+
models::check_xss_map, models::check_xss_map_nested, models::check_xss_map_string,
20+
models::check_xss_string, models::check_xss_vec_string,
21+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#[tracing::instrument(skip_all)]
33
async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}<I, A, E{{#havingAuthMethod}}, C{{/havingAuthMethod}}>(
44
method: Method,
5-
host: Host,
5+
TypedHeader(host): TypedHeader<Host>,
66
cookies: CookieJar,
77
{{#headerParams.size}}
88
headers: HeaderMap,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.18.0-SNAPSHOT
1+
7.19.0-SNAPSHOT

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ conversion = [
2121
ammonia = "4"
2222
async-trait = "0.1"
2323
axum = { version = "0.8", features = ["multipart"] }
24-
axum-extra = { version = "0.12", features = ["cookie", "query"] }
24+
axum-extra = { version = "0.12", features = [
25+
"cookie",
26+
"query",
27+
"typed-header",
28+
] }
2529
base64 = "0.22"
2630
bytes = "1"
2731
chrono = { version = "0.4", features = ["serde"] }
@@ -30,6 +34,7 @@ frunk-enum-core = { version = "0.3", optional = true }
3034
frunk-enum-derive = { version = "0.3", optional = true }
3135
frunk_core = { version = "0.4", optional = true }
3236
frunk_derives = { version = "0.4", optional = true }
37+
headers = "0.4"
3338
http = "1"
3439
lazy_static = "1"
3540
regex = "1"

samples/server/petstore/rust-axum/output/apikey-authorization/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0.0
15-
- Generator version: 7.18.0-SNAPSHOT
15+
- Generator version: 7.19.0-SNAPSHOT
1616

1717

1818

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
8585
async fn handle_error(
8686
&self,
8787
method: &::http::Method,
88-
host: &axum_extra::extract::Host,
88+
host: &headers::Host,
8989
cookies: &axum_extra::extract::CookieJar,
9090
error: E,
9191
) -> Result<axum::response::Response, http::StatusCode> {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use async_trait::async_trait;
22
use axum::extract::*;
3-
use axum_extra::extract::{CookieJar, Host};
3+
use axum_extra::extract::CookieJar;
44
use bytes::Bytes;
5+
use headers::Host;
56
use http::Method;
67
use serde::{Deserialize, Serialize};
78

0 commit comments

Comments
 (0)