Skip to content

Commit 71c367a

Browse files
myz-devMert Yildiz
authored andcommitted
test: Update examples and run integration test
Running `./bin/generate-samples.sh ./bin/configs/manual/*.yaml` updated all examples. Most of them contain changes to their previously checked in version that are not related to the fix for #18554. `mvn integration-test -f samples/server/petstore/rust-axum/pom.xml` passes.
1 parent 88420a7 commit 71c367a

File tree

24 files changed

+1513
-41
lines changed

24 files changed

+1513
-41
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.0-SNAPSHOT
1+
7.6.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.5.0-SNAPSHOT
15+
- Generator version: 7.6.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.0-SNAPSHOT
1+
7.6.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.5.0-SNAPSHOT
15+
- Generator version: 7.6.0-SNAPSHOT
1616

1717

1818

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{convert::TryFrom, fmt, ops::Deref};
1+
use std::{convert::TryFrom, fmt, ops::Deref, str::FromStr};
22

33
use chrono::{DateTime, Utc};
44
use http::HeaderValue;
@@ -195,3 +195,36 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
195195
}
196196
}
197197
}
198+
199+
// uuid::Uuid
200+
201+
impl TryFrom<HeaderValue> for IntoHeaderValue<uuid::Uuid> {
202+
type Error = String;
203+
204+
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
205+
match hdr_value.to_str() {
206+
Ok(hdr_value) => match uuid::Uuid::from_str(hdr_value) {
207+
Ok(uuid) => Ok(IntoHeaderValue(uuid)),
208+
Err(e) => Err(format!("Unable to parse: {} as uuid - {}", hdr_value, e)),
209+
},
210+
Err(e) => Err(format!(
211+
"Unable to convert header {:?} to string {}",
212+
hdr_value, e
213+
)),
214+
}
215+
}
216+
}
217+
218+
impl TryFrom<IntoHeaderValue<uuid::Uuid>> for HeaderValue {
219+
type Error = String;
220+
221+
fn try_from(hdr_value: IntoHeaderValue<uuid::Uuid>) -> Result<Self, Self::Error> {
222+
match HeaderValue::from_bytes(hdr_value.0.as_bytes()) {
223+
Ok(hdr_value) => Ok(hdr_value),
224+
Err(e) => Err(format!(
225+
"Unable to convert {:?} to a header: {}",
226+
hdr_value, e
227+
)),
228+
}
229+
}
230+
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ pub enum UuidGetResponse {
204204
Status200_DuplicateResponseLongText(uuid::Uuid),
205205
}
206206

207+
#[derive(Debug, PartialEq, Serialize, Deserialize)]
208+
#[must_use]
209+
#[allow(clippy::large_enum_variant)]
210+
pub enum UuidInHeaderGetResponse {
211+
/// Test uuid deserialization from header value.
212+
Status200_TestUuidDeserializationFromHeaderValue,
213+
}
214+
207215
#[derive(Debug, PartialEq, Serialize, Deserialize)]
208216
#[must_use]
209217
#[allow(clippy::large_enum_variant)]
@@ -440,6 +448,15 @@ pub trait Api {
440448
cookies: CookieJar,
441449
) -> Result<UuidGetResponse, String>;
442450

451+
/// UuidInHeaderGet - GET /uuid_in_header
452+
async fn uuid_in_header_get(
453+
&self,
454+
method: Method,
455+
host: Host,
456+
cookies: CookieJar,
457+
header_params: models::UuidInHeaderGetHeaderParams,
458+
) -> Result<UuidInHeaderGetResponse, String>;
459+
443460
/// XmlExtraPost - POST /xml_extra
444461
async fn xml_extra_post(
445462
&self,

samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ pub struct RegisterCallbackPostQueryParams {
7676
pub url: String,
7777
}
7878

79+
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
80+
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
81+
pub struct UuidInHeaderGetHeaderParams {
82+
pub some_uid: uuid::Uuid,
83+
}
84+
7985
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
8086
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
8187
pub struct GetRepoInfoPathParams {

samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ use crate::{
1919
MultigetGetResponse, MultipleAuthSchemeGetResponse, OneOfGetResponse,
2020
OverrideServerGetResponse, ParamgetGetResponse, ReadonlyAuthSchemeGetResponse,
2121
RegisterCallbackPostResponse, RequiredOctetStreamPutResponse, ResponsesWithHeadersGetResponse,
22-
Rfc7807GetResponse, UntypedPropertyGetResponse, UuidGetResponse, XmlExtraPostResponse,
23-
XmlOtherPostResponse, XmlOtherPutResponse, XmlPostResponse, XmlPutResponse,
22+
Rfc7807GetResponse, UntypedPropertyGetResponse, UuidGetResponse, UuidInHeaderGetResponse,
23+
XmlExtraPostResponse, XmlOtherPostResponse, XmlOtherPutResponse, XmlPostResponse,
24+
XmlPutResponse,
2425
};
2526

2627
/// Setup API Server.
@@ -79,6 +80,7 @@ where
7980
.route("/rfc7807", get(rfc7807_get::<I, A>))
8081
.route("/untyped_property", get(untyped_property_get::<I, A>))
8182
.route("/uuid", get(uuid_get::<I, A>))
83+
.route("/uuid_in_header", get(uuid_in_header_get::<I, A>))
8284
.route("/xml", post(xml_post::<I, A>).put(xml_put::<I, A>))
8385
.route("/xml_extra", post(xml_extra_post::<I, A>))
8486
.route(
@@ -1606,6 +1608,96 @@ where
16061608
})
16071609
}
16081610

1611+
#[tracing::instrument(skip_all)]
1612+
fn uuid_in_header_get_validation(
1613+
header_params: models::UuidInHeaderGetHeaderParams,
1614+
) -> std::result::Result<(models::UuidInHeaderGetHeaderParams,), ValidationErrors> {
1615+
header_params.validate()?;
1616+
1617+
Ok((header_params,))
1618+
}
1619+
/// UuidInHeaderGet - GET /uuid_in_header
1620+
#[tracing::instrument(skip_all)]
1621+
async fn uuid_in_header_get<I, A>(
1622+
method: Method,
1623+
host: Host,
1624+
cookies: CookieJar,
1625+
headers: HeaderMap,
1626+
State(api_impl): State<I>,
1627+
) -> Result<Response, StatusCode>
1628+
where
1629+
I: AsRef<A> + Send + Sync,
1630+
A: Api,
1631+
{
1632+
// Header parameters
1633+
let header_params = {
1634+
let header_some_uid = headers.get(HeaderName::from_static("some_uid"));
1635+
1636+
let header_some_uid = match header_some_uid {
1637+
Some(v) => match header::IntoHeaderValue::<uuid::Uuid>::try_from((*v).clone()) {
1638+
Ok(result) => result.0,
1639+
Err(err) => {
1640+
return Response::builder()
1641+
.status(StatusCode::BAD_REQUEST)
1642+
.body(Body::from(format!("Invalid header some_uid - {}", err)))
1643+
.map_err(|e| {
1644+
error!(error = ?e);
1645+
StatusCode::INTERNAL_SERVER_ERROR
1646+
});
1647+
}
1648+
},
1649+
None => {
1650+
return Response::builder()
1651+
.status(StatusCode::BAD_REQUEST)
1652+
.body(Body::from("Missing required header some_uid"))
1653+
.map_err(|e| {
1654+
error!(error = ?e);
1655+
StatusCode::INTERNAL_SERVER_ERROR
1656+
});
1657+
}
1658+
};
1659+
1660+
models::UuidInHeaderGetHeaderParams {
1661+
some_uid: header_some_uid,
1662+
}
1663+
};
1664+
1665+
let validation = uuid_in_header_get_validation(header_params);
1666+
1667+
let Ok((header_params,)) = validation else {
1668+
return Response::builder()
1669+
.status(StatusCode::BAD_REQUEST)
1670+
.body(Body::from(validation.unwrap_err().to_string()))
1671+
.map_err(|_| StatusCode::BAD_REQUEST);
1672+
};
1673+
1674+
let result = api_impl
1675+
.as_ref()
1676+
.uuid_in_header_get(method, host, cookies, header_params)
1677+
.await;
1678+
1679+
let mut response = Response::builder();
1680+
1681+
let resp = match result {
1682+
Ok(rsp) => match rsp {
1683+
UuidInHeaderGetResponse::Status200_TestUuidDeserializationFromHeaderValue => {
1684+
let mut response = response.status(200);
1685+
response.body(Body::empty())
1686+
}
1687+
},
1688+
Err(_) => {
1689+
// Application code returned an error. This should not happen, as the implementation should
1690+
// return a valid response.
1691+
response.status(500).body(Body::empty())
1692+
}
1693+
};
1694+
1695+
resp.map_err(|e| {
1696+
error!(error = ?e);
1697+
StatusCode::INTERNAL_SERVER_ERROR
1698+
})
1699+
}
1700+
16091701
#[derive(validator::Validate)]
16101702
#[allow(dead_code)]
16111703
struct XmlExtraPostBodyValidator<'a> {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.0-SNAPSHOT
1+
7.6.0-SNAPSHOT

samples/server/petstore/rust-axum/output/ops-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: 0.0.1
15-
- Generator version: 7.5.0-SNAPSHOT
15+
- Generator version: 7.6.0-SNAPSHOT
1616

1717

1818

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.0-SNAPSHOT
1+
7.6.0-SNAPSHOT

samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/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.5.0-SNAPSHOT
15+
- Generator version: 7.6.0-SNAPSHOT
1616

1717

1818

samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ pub trait Api {
445445
method: Method,
446446
host: Host,
447447
cookies: CookieJar,
448+
body: models::TestEndpointParametersRequest,
448449
) -> Result<TestEndpointParametersResponse, String>;
449450

450451
/// To test enum parameters.
@@ -457,6 +458,7 @@ pub trait Api {
457458
cookies: CookieJar,
458459
header_params: models::TestEnumParametersHeaderParams,
459460
query_params: models::TestEnumParametersQueryParams,
461+
body: Option<models::TestEnumParametersRequest>,
460462
) -> Result<TestEnumParametersResponse, String>;
461463

462464
/// test inline additionalProperties.
@@ -478,6 +480,7 @@ pub trait Api {
478480
method: Method,
479481
host: Host,
480482
cookies: CookieJar,
483+
body: models::TestJsonFormDataRequest,
481484
) -> Result<TestJsonFormDataResponse, String>;
482485

483486
/// To test class name in snake case.
@@ -567,6 +570,7 @@ pub trait Api {
567570
host: Host,
568571
cookies: CookieJar,
569572
path_params: models::UpdatePetWithFormPathParams,
573+
body: Option<models::UpdatePetWithFormRequest>,
570574
) -> Result<UpdatePetWithFormResponse, String>;
571575

572576
/// uploads an image.

0 commit comments

Comments
 (0)