Skip to content

Commit 9a4dad3

Browse files
chore: run the updated rust-axum sample
1 parent 932c047 commit 9a4dad3

40 files changed

Lines changed: 117 additions & 265 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.13.0-SNAPSHOT
1+
7.12.0-SNAPSHOT

samples/server/petstore/rust-axum/output/apikey-auths/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.13.0-SNAPSHOT
15+
- Generator version: 7.12.0-SNAPSHOT
1616

1717

1818

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ pub trait CookieAuthentication {
2626
) -> Option<Self::Claims>;
2727
}
2828

29-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
30-
#[non_exhaustive]
31-
pub enum BasicAuthKind {
32-
Basic,
33-
Bearer,
34-
}
35-
36-
/// API Key Authentication - Authentication Header.
37-
/// For `Basic token` and `Bearer token`
38-
#[async_trait::async_trait]
39-
pub trait ApiAuthBasic {
40-
type Claims;
41-
42-
/// Extracting Claims from Header. Return None if the Claims are invalid.
43-
async fn extract_claims_from_auth_header(
44-
&self,
45-
kind: BasicAuthKind,
46-
headers: &axum::http::header::HeaderMap,
47-
key: &str,
48-
) -> Option<Self::Claims>;
49-
}
50-
5129
// Error handler for unhandled errors.
5230
#[async_trait::async_trait]
5331
pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub trait Payments<E: std::fmt::Debug + Send + Sync + 'static = ()>:
5151
method: &Method,
5252
host: &Host,
5353
cookies: &CookieJar,
54-
claims: &Self::Claims,
5554
path_params: &models::GetPaymentMethodByIdPathParams,
5655
) -> Result<GetPaymentMethodByIdResponse, E>;
5756

@@ -63,7 +62,6 @@ pub trait Payments<E: std::fmt::Debug + Send + Sync + 'static = ()>:
6362
method: &Method,
6463
host: &Host,
6564
cookies: &CookieJar,
66-
claims: &Self::Claims,
6765
) -> Result<GetPaymentMethodsResponse, E>;
6866

6967
/// Make a payment.

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

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ where
3434
get(get_payment_methods::<I, A, E, C>),
3535
)
3636
.route(
37-
"/v71/paymentMethods/{id}",
37+
"/v71/paymentMethods/:id",
3838
get(get_payment_method_by_id::<I, A, E, C>),
3939
)
4040
.route("/v71/payments", post(post_make_payment::<I, A, E, C>))
@@ -55,28 +55,14 @@ async fn get_payment_method_by_id<I, A, E, C>(
5555
method: Method,
5656
host: Host,
5757
cookies: CookieJar,
58-
headers: HeaderMap,
5958
Path(path_params): Path<models::GetPaymentMethodByIdPathParams>,
6059
State(api_impl): State<I>,
6160
) -> Result<Response, StatusCode>
6261
where
6362
I: AsRef<A> + Send + Sync,
64-
A: apis::payments::Payments<E, Claims = C> + apis::ApiAuthBasic<Claims = C> + Send + Sync,
63+
A: apis::payments::Payments<E, Claims = C> + Send + Sync,
6564
E: std::fmt::Debug + Send + Sync + 'static,
6665
{
67-
// Authentication
68-
let claims_in_auth_header = api_impl
69-
.as_ref()
70-
.extract_claims_from_auth_header(apis::BasicAuthKind::Bearer, &headers, "authorization")
71-
.await;
72-
let claims = None.or(claims_in_auth_header);
73-
let Some(claims) = claims else {
74-
return Response::builder()
75-
.status(StatusCode::UNAUTHORIZED)
76-
.body(Body::empty())
77-
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
78-
};
79-
8066
#[allow(clippy::redundant_closure)]
8167
let validation =
8268
tokio::task::spawn_blocking(move || get_payment_method_by_id_validation(path_params))
@@ -92,7 +78,7 @@ where
9278

9379
let result = api_impl
9480
.as_ref()
95-
.get_payment_method_by_id(&method, &host, &cookies, &claims, &path_params)
81+
.get_payment_method_by_id(&method, &host, &cookies, &path_params)
9682
.await;
9783

9884
let mut response = Response::builder();
@@ -172,27 +158,13 @@ async fn get_payment_methods<I, A, E, C>(
172158
method: Method,
173159
host: Host,
174160
cookies: CookieJar,
175-
headers: HeaderMap,
176161
State(api_impl): State<I>,
177162
) -> Result<Response, StatusCode>
178163
where
179164
I: AsRef<A> + Send + Sync,
180-
A: apis::payments::Payments<E, Claims = C> + apis::ApiAuthBasic<Claims = C> + Send + Sync,
165+
A: apis::payments::Payments<E, Claims = C> + Send + Sync,
181166
E: std::fmt::Debug + Send + Sync + 'static,
182167
{
183-
// Authentication
184-
let claims_in_auth_header = api_impl
185-
.as_ref()
186-
.extract_claims_from_auth_header(apis::BasicAuthKind::Bearer, &headers, "authorization")
187-
.await;
188-
let claims = None.or(claims_in_auth_header);
189-
let Some(claims) = claims else {
190-
return Response::builder()
191-
.status(StatusCode::UNAUTHORIZED)
192-
.body(Body::empty())
193-
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
194-
};
195-
196168
#[allow(clippy::redundant_closure)]
197169
let validation = tokio::task::spawn_blocking(move || get_payment_methods_validation())
198170
.await
@@ -207,7 +179,7 @@ where
207179

208180
let result = api_impl
209181
.as_ref()
210-
.get_payment_methods(&method, &host, &cookies, &claims)
182+
.get_payment_methods(&method, &host, &cookies)
211183
.await;
212184

213185
let mut response = Response::builder();
@@ -278,15 +250,13 @@ async fn post_make_payment<I, A, E, C>(
278250
method: Method,
279251
host: Host,
280252
cookies: CookieJar,
281-
headers: HeaderMap,
282253
State(api_impl): State<I>,
283254
Json(body): Json<Option<models::Payment>>,
284255
) -> Result<Response, StatusCode>
285256
where
286257
I: AsRef<A> + Send + Sync,
287258
A: apis::payments::Payments<E, Claims = C>
288259
+ apis::CookieAuthentication<Claims = C>
289-
+ apis::ApiAuthBasic<Claims = C>
290260
+ Send
291261
+ Sync,
292262
E: std::fmt::Debug + Send + Sync + 'static,
@@ -296,11 +266,7 @@ where
296266
.as_ref()
297267
.extract_claims_from_cookie(&cookies, "X-API-Key")
298268
.await;
299-
let claims_in_auth_header = api_impl
300-
.as_ref()
301-
.extract_claims_from_auth_header(apis::BasicAuthKind::Bearer, &headers, "authorization")
302-
.await;
303-
let claims = None.or(claims_in_cookie).or(claims_in_auth_header);
269+
let claims = None.or(claims_in_cookie);
304270
let Some(claims) = claims else {
305271
return Response::builder()
306272
.status(StatusCode::UNAUTHORIZED)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.13.0-SNAPSHOT
1+
7.12.0-SNAPSHOT

samples/server/petstore/rust-axum/output/multipart-v3/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.7
15-
- Generator version: 7.13.0-SNAPSHOT
15+
- Generator version: 7.12.0-SNAPSHOT
1616

1717

1818

samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub trait Default<E: std::fmt::Debug + Send + Sync + 'static = ()>: super::Error
4141
method: &Method,
4242
host: &Host,
4343
cookies: &CookieJar,
44-
body: &axum::body::Body,
44+
body: axum::body::Body,
4545
) -> Result<MultipartRelatedRequestPostResponse, E>;
4646

4747
/// MultipartRequestPost - POST /multipart_request
@@ -50,7 +50,7 @@ pub trait Default<E: std::fmt::Debug + Send + Sync + 'static = ()>: super::Error
5050
method: &Method,
5151
host: &Host,
5252
cookies: &CookieJar,
53-
body: &Multipart,
53+
body: Multipart,
5454
) -> Result<MultipartRequestPostResponse, E>;
5555

5656
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
@@ -59,6 +59,6 @@ pub trait Default<E: std::fmt::Debug + Send + Sync + 'static = ()>: super::Error
5959
method: &Method,
6060
host: &Host,
6161
cookies: &CookieJar,
62-
body: &axum::body::Body,
62+
body: axum::body::Body,
6363
) -> Result<MultipleIdenticalMimeTypesPostResponse, E>;
6464
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.13.0-SNAPSHOT
1+
7.12.0-SNAPSHOT

samples/server/petstore/rust-axum/output/openapi-v3/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.7
15-
- Generator version: 7.13.0-SNAPSHOT
15+
- Generator version: 7.12.0-SNAPSHOT
1616

1717

1818

0 commit comments

Comments
 (0)