Skip to content

Commit d6a7d48

Browse files
chore: run the updated rust-axum sample (2)
Notes: Ran ./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
1 parent 9a4dad3 commit d6a7d48

10 files changed

Lines changed: 393 additions & 479 deletions

File tree

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

samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "rust-axum-oneof"
2+
name = "openapi-v3"
33
version = "0.0.1"
44
authors = ["OpenAPI Generator team and contributors"]
55
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"

samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Rust API for rust-axum-oneof
1+
# Rust API for openapi-v3
22

33
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44

@@ -12,11 +12,11 @@ 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: 0.0.1
15-
- Generator version: 7.12.0-SNAPSHOT
15+
- Generator version: 7.14.0-SNAPSHOT
1616

1717

1818

19-
This autogenerated project defines an API crate `rust-axum-oneof` which contains:
19+
This autogenerated project defines an API crate `openapi-v3` which contains:
2020
* An `Api` trait defining the API in Rust.
2121
* Data types representing the underlying data model.
2222
* Axum router which accepts HTTP requests and invokes the appropriate `Api` method for each operation.
@@ -43,18 +43,18 @@ struct ServerImpl {
4343

4444
#[allow(unused_variables)]
4545
#[async_trait]
46-
impl rust_axum_oneof::apis::default::Api for ServerImpl {
46+
impl openapi_v3::apis::default::Api for ServerImpl {
4747
// API implementation goes here
4848
}
4949

50-
impl rust_axum_oneof::apis::ErrorHandler for ServerImpl {}
50+
impl openapi_v3::apis::ErrorHandler for ServerImpl {}
5151

5252
pub async fn start_server(addr: &str) {
5353
// initialize tracing
5454
tracing_subscriber::fmt::init();
5555

5656
// Init Axum router
57-
let app = rust_axum_oneof::server::new(Arc::new(ServerImpl));
57+
let app = openapi_v3::server::new(Arc::new(ServerImpl));
5858

5959
// Add layers to the router
6060
let app = app.layer(...);

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ use crate::{models, types::*};
1212
#[allow(clippy::large_enum_variant)]
1313
pub enum FooResponse {
1414
/// Re-serialize and echo the request data
15-
Status200_Re(models::Message),
15+
Status200_Re
16+
(models::Message)
1617
}
1718

19+
1820
/// Default
1921
#[async_trait]
2022
#[allow(clippy::ptr_arg)]
2123
pub trait Default<E: std::fmt::Debug + Send + Sync + 'static = ()>: super::ErrorHandler<E> {
2224
/// Foo - POST /
2325
async fn foo(
24-
&self,
25-
method: &Method,
26-
host: &Host,
27-
cookies: &CookieJar,
28-
body: &models::Message,
26+
&self,
27+
method: &Method,
28+
host: &Host,
29+
cookies: &CookieJar,
30+
body: &models::Message,
2931
) -> Result<FooResponse, E>;
3032
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod default;
22

3+
34
// Error handler for unhandled errors.
45
#[async_trait::async_trait]
56
pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
@@ -10,7 +11,7 @@ pub trait ErrorHandler<E: std::fmt::Debug + Send + Sync + 'static = ()> {
1011
method: &::http::Method,
1112
host: &axum_extra::extract::Host,
1213
cookies: &axum_extra::extract::CookieJar,
13-
error: E,
14+
error: E
1415
) -> Result<axum::response::Response, http::StatusCode> {
1516
tracing::error!("Unhandled error: {:?}", error);
1617
axum::response::Response::builder()

samples/server/petstore/rust-axum/output/rust-axum-oneof/src/header.rs

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
3030
match hdr_value.to_str() {
3131
Ok(hdr_value) => match hdr_value.parse::<$t>() {
3232
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
33-
Err(e) => Err(format!(
34-
"Unable to parse {} as a string: {}",
35-
stringify!($t),
36-
e
37-
)),
33+
Err(e) => Err(format!("Unable to parse {} as a string: {}",
34+
stringify!($t), e)),
3835
},
39-
Err(e) => Err(format!(
40-
"Unable to parse header {:?} as a string - {}",
41-
hdr_value, e
42-
)),
36+
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
37+
hdr_value, e)),
4338
}
4439
}
4540
}
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
7469
match hdr_value.to_str() {
7570
Ok(hdr_value) => Ok(IntoHeaderValue(
7671
hdr_value
77-
.split(',')
78-
.filter_map(|x| match x.trim() {
79-
"" => None,
80-
y => Some(y.to_string()),
81-
})
82-
.collect(),
83-
)),
84-
Err(e) => Err(format!(
85-
"Unable to parse header: {:?} as a string - {}",
86-
hdr_value, e
87-
)),
72+
.split(',')
73+
.filter_map(|x| match x.trim() {
74+
"" => None,
75+
y => Some(y.to_string()),
76+
})
77+
.collect())),
78+
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
79+
hdr_value, e)),
8880
}
8981
}
9082
}
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
9385
type Error = String;
9486

9587
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
96-
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
97-
Ok(hdr_value) => Ok(hdr_value),
98-
Err(e) => Err(format!(
99-
"Unable to convert {:?} into a header - {}",
100-
hdr_value, e
101-
)),
102-
}
88+
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
89+
Ok(hdr_value) => Ok(hdr_value),
90+
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
91+
hdr_value, e))
92+
}
10393
}
10494
}
10595

@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
111101
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
112102
match hdr_value.to_str() {
113103
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
114-
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
104+
Err(e) => Err(format!("Unable to convert header {:?} to {}",
105+
hdr_value, e)),
115106
}
116107
}
117108
}
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
122113
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
123114
match HeaderValue::from_str(&hdr_value.0) {
124115
Ok(hdr_value) => Ok(hdr_value),
125-
Err(e) => Err(format!(
126-
"Unable to convert {:?} from a header {}",
127-
hdr_value, e
128-
)),
116+
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
117+
hdr_value, e))
129118
}
130119
}
131120
}
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
139128
match hdr_value.to_str() {
140129
Ok(hdr_value) => match hdr_value.parse() {
141130
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
142-
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
131+
Err(e) => Err(format!("Unable to parse bool from {} - {}",
132+
hdr_value, e)),
143133
},
144-
Err(e) => Err(format!(
145-
"Unable to convert {:?} from a header {}",
146-
hdr_value, e
147-
)),
134+
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
135+
hdr_value, e)),
148136
}
149137
}
150138
}
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
155143
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
156144
match HeaderValue::from_str(&hdr_value.0.to_string()) {
157145
Ok(hdr_value) => Ok(hdr_value),
158-
Err(e) => Err(format!(
159-
"Unable to convert: {:?} into a header: {}",
160-
hdr_value, e
161-
)),
146+
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
147+
hdr_value, e))
162148
}
163149
}
164150
}
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
172158
match hdr_value.to_str() {
173159
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
174160
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
175-
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
161+
Err(e) => Err(format!("Unable to parse: {} as date - {}",
162+
hdr_value, e)),
176163
},
177-
Err(e) => Err(format!(
178-
"Unable to convert header {:?} to string {}",
179-
hdr_value, e
180-
)),
164+
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
165+
hdr_value, e)),
181166
}
182167
}
183168
}
@@ -188,10 +173,9 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
188173
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
189174
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
190175
Ok(hdr_value) => Ok(hdr_value),
191-
Err(e) => Err(format!(
192-
"Unable to convert {:?} to a header: {}",
193-
hdr_value, e
194-
)),
176+
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
177+
hdr_value, e)),
195178
}
196179
}
197180
}
181+

samples/server/petstore/rust-axum/output/rust-axum-oneof/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
unused_extern_crates,
77
non_camel_case_types,
88
unused_imports,
9-
unused_attributes
9+
unused_attributes,
1010
)]
1111
#![allow(
1212
clippy::derive_partial_eq_without_eq,
@@ -20,9 +20,9 @@ pub const API_VERSION: &str = "0.0.1";
2020
#[cfg(feature = "server")]
2121
pub mod server;
2222

23-
pub mod apis;
2423
pub mod models;
2524
pub mod types;
25+
pub mod apis;
2626

2727
#[cfg(feature = "server")]
2828
pub(crate) mod header;

0 commit comments

Comments
 (0)