Skip to content

Commit 70f90bf

Browse files
committed
re-gen samples
1 parent a6e19c2 commit 70f90bf

9 files changed

Lines changed: 109 additions & 116 deletions

File tree

samples/client/others/rust/reqwest/multipart-async/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ serde = { version = "^1.0", features = ["derive"] }
1212
serde_json = "^1.0"
1313
serde_repr = "^0.1"
1414
url = "^2.5"
15-
tokio = { version = "^1.46.0", features = ["fs", "macros", "rt-multi-thread"] }
15+
tokio = { version = "^1.46.0", features = ["fs"] }
1616
tokio-util = { version = "^0.7", features = ["codec"] }
1717
reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "stream"] }
1818

1919
[dev-dependencies]
20-
tokio = { version = "^1.46.0", features = ["fs", "macros", "rt-multi-thread", "test-util"] }
20+
tokio = { version = "^1.46.0", features = ["macros", "rt-multi-thread", "test-util"] }
2121

2222
[features]
2323
default = ["native-tls"]

samples/client/petstore/rust/reqwest/petstore/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ serde_json = "^1.0"
1313
serde_repr = "^0.1"
1414
url = "^2.5"
1515
uuid = { version = "^1.8", features = ["serde", "v4"] }
16-
tokio = { version = "^1.46.0", features = ["fs"] }
17-
tokio-util = { version = "^0.7", features = ["codec"] }
18-
reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "stream"] }
16+
reqwest = { version = "^0.12", default-features = false, features = ["json", "blocking", "multipart"] }
1917

2018
[dev-dependencies]
2119
wiremock = "0.6"

samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
pub struct Configuration {
1515
pub base_path: String,
1616
pub user_agent: Option<String>,
17-
pub client: reqwest::Client,
17+
pub client: reqwest::blocking::Client,
1818
pub basic_auth: Option<BasicAuth>,
1919
pub oauth_access_token: Option<String>,
2020
pub bearer_access_token: Option<String>,
@@ -41,7 +41,7 @@ impl Default for Configuration {
4141
Configuration {
4242
base_path: "http://localhost/v2".to_owned(),
4343
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
44-
client: reqwest::Client::new(),
44+
client: reqwest::blocking::Client::new(),
4545
basic_auth: None,
4646
oauth_access_token: None,
4747
bearer_access_token: None,

samples/client/petstore/rust/reqwest/petstore/src/apis/fake_api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum TestNullableRequiredParamError {
2626

2727

2828
///
29-
pub async fn test_nullable_required_param(configuration: &configuration::Configuration, user_name: &str, dummy_required_nullable_param: Option<&str>, any_type: &str, uppercase: Option<&str>, content: Option<&str>) -> Result<(), Error<TestNullableRequiredParamError>> {
29+
pub fn test_nullable_required_param(configuration: &configuration::Configuration, user_name: &str, dummy_required_nullable_param: Option<&str>, any_type: &str, uppercase: Option<&str>, content: Option<&str>) -> Result<(), Error<TestNullableRequiredParamError>> {
3030
// add a prefix to parameters to efficiently prevent name collisions
3131
let p_path_user_name = user_name;
3232
let p_header_dummy_required_nullable_param = dummy_required_nullable_param;
@@ -53,14 +53,14 @@ pub async fn test_nullable_required_param(configuration: &configuration::Configu
5353
}
5454

5555
let req = req_builder.build()?;
56-
let resp = configuration.client.execute(req).await?;
56+
let resp = configuration.client.execute(req)?;
5757

5858
let status = resp.status();
5959

6060
if !status.is_client_error() && !status.is_server_error() {
6161
Ok(())
6262
} else {
63-
let content = resp.text().await?;
63+
let content = resp.text()?;
6464
let entity: Option<TestNullableRequiredParamError> = serde_json::from_str(&content).ok();
6565
Err(Error::ResponseError(ResponseContent { status, content, entity }))
6666
}

samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs

Lines changed: 40 additions & 45 deletions
Large diffs are not rendered by default.

samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub enum PlaceOrderError {
5050

5151

5252
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
53-
pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<DeleteOrderError>> {
53+
pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<DeleteOrderError>> {
5454
// add a prefix to parameters to efficiently prevent name collisions
5555
let p_path_order_id = order_id;
5656

@@ -62,21 +62,21 @@ pub async fn delete_order(configuration: &configuration::Configuration, order_id
6262
}
6363

6464
let req = req_builder.build()?;
65-
let resp = configuration.client.execute(req).await?;
65+
let resp = configuration.client.execute(req)?;
6666

6767
let status = resp.status();
6868

6969
if !status.is_client_error() && !status.is_server_error() {
7070
Ok(())
7171
} else {
72-
let content = resp.text().await?;
72+
let content = resp.text()?;
7373
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
7474
Err(Error::ResponseError(ResponseContent { status, content, entity }))
7575
}
7676
}
7777

7878
/// Returns a map of status codes to quantities
79-
pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, i32>, Error<GetInventoryError>> {
79+
pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, i32>, Error<GetInventoryError>> {
8080

8181
let uri_str = format!("{}/store/inventory", configuration.base_path);
8282
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
@@ -94,7 +94,7 @@ pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Re
9494
};
9595

9696
let req = req_builder.build()?;
97-
let resp = configuration.client.execute(req).await?;
97+
let resp = configuration.client.execute(req)?;
9898

9999
let status = resp.status();
100100
let content_type = resp
@@ -105,21 +105,21 @@ pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Re
105105
let content_type = super::ContentType::from(content_type);
106106

107107
if !status.is_client_error() && !status.is_server_error() {
108-
let content = resp.text().await?;
108+
let content = resp.text()?;
109109
match content_type {
110110
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
111111
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, i32&gt;`"))),
112112
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, i32&gt;`")))),
113113
}
114114
} else {
115-
let content = resp.text().await?;
115+
let content = resp.text()?;
116116
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
117117
Err(Error::ResponseError(ResponseContent { status, content, entity }))
118118
}
119119
}
120120

121121
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
122-
pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<models::Order, Error<GetOrderByIdError>> {
122+
pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<models::Order, Error<GetOrderByIdError>> {
123123
// add a prefix to parameters to efficiently prevent name collisions
124124
let p_path_order_id = order_id;
125125

@@ -131,7 +131,7 @@ pub async fn get_order_by_id(configuration: &configuration::Configuration, order
131131
}
132132

133133
let req = req_builder.build()?;
134-
let resp = configuration.client.execute(req).await?;
134+
let resp = configuration.client.execute(req)?;
135135

136136
let status = resp.status();
137137
let content_type = resp
@@ -142,21 +142,21 @@ pub async fn get_order_by_id(configuration: &configuration::Configuration, order
142142
let content_type = super::ContentType::from(content_type);
143143

144144
if !status.is_client_error() && !status.is_server_error() {
145-
let content = resp.text().await?;
145+
let content = resp.text()?;
146146
match content_type {
147147
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148148
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
149149
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))),
150150
}
151151
} else {
152-
let content = resp.text().await?;
152+
let content = resp.text()?;
153153
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
154154
Err(Error::ResponseError(ResponseContent { status, content, entity }))
155155
}
156156
}
157157

158158
///
159-
pub async fn place_order(configuration: &configuration::Configuration, order: models::Order) -> Result<models::Order, Error<PlaceOrderError>> {
159+
pub fn place_order(configuration: &configuration::Configuration, order: models::Order) -> Result<models::Order, Error<PlaceOrderError>> {
160160
// add a prefix to parameters to efficiently prevent name collisions
161161
let p_body_order = order;
162162

@@ -169,7 +169,7 @@ pub async fn place_order(configuration: &configuration::Configuration, order: mo
169169
req_builder = req_builder.json(&p_body_order);
170170

171171
let req = req_builder.build()?;
172-
let resp = configuration.client.execute(req).await?;
172+
let resp = configuration.client.execute(req)?;
173173

174174
let status = resp.status();
175175
let content_type = resp
@@ -180,14 +180,14 @@ pub async fn place_order(configuration: &configuration::Configuration, order: mo
180180
let content_type = super::ContentType::from(content_type);
181181

182182
if !status.is_client_error() && !status.is_server_error() {
183-
let content = resp.text().await?;
183+
let content = resp.text()?;
184184
match content_type {
185185
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186186
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
187187
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))),
188188
}
189189
} else {
190-
let content = resp.text().await?;
190+
let content = resp.text()?;
191191
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
192192
Err(Error::ResponseError(ResponseContent { status, content, entity }))
193193
}

samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum TestsTypeTestingGetError {
5151
}
5252

5353

54-
pub async fn tests_all_of_with_one_model_get(configuration: &configuration::Configuration, person: models::Person) -> Result<String, Error<TestsAllOfWithOneModelGetError>> {
54+
pub fn tests_all_of_with_one_model_get(configuration: &configuration::Configuration, person: models::Person) -> Result<String, Error<TestsAllOfWithOneModelGetError>> {
5555
// add a prefix to parameters to efficiently prevent name collisions
5656
let p_body_person = person;
5757

@@ -64,7 +64,7 @@ pub async fn tests_all_of_with_one_model_get(configuration: &configuration::Conf
6464
req_builder = req_builder.json(&p_body_person);
6565

6666
let req = req_builder.build()?;
67-
let resp = configuration.client.execute(req).await?;
67+
let resp = configuration.client.execute(req)?;
6868

6969
let status = resp.status();
7070
let content_type = resp
@@ -75,20 +75,20 @@ pub async fn tests_all_of_with_one_model_get(configuration: &configuration::Conf
7575
let content_type = super::ContentType::from(content_type);
7676

7777
if !status.is_client_error() && !status.is_server_error() {
78-
let content = resp.text().await?;
78+
let content = resp.text()?;
7979
match content_type {
8080
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8181
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
8282
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
8383
}
8484
} else {
85-
let content = resp.text().await?;
85+
let content = resp.text()?;
8686
let entity: Option<TestsAllOfWithOneModelGetError> = serde_json::from_str(&content).ok();
8787
Err(Error::ResponseError(ResponseContent { status, content, entity }))
8888
}
8989
}
9090

91-
pub async fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result<reqwest::Response, Error<TestsFileResponseGetError>> {
91+
pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result<reqwest::blocking::Response, Error<TestsFileResponseGetError>> {
9292

9393
let uri_str = format!("{}/tests/fileResponse", configuration.base_path);
9494
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
@@ -98,21 +98,21 @@ pub async fn tests_file_response_get(configuration: &configuration::Configuratio
9898
}
9999

100100
let req = req_builder.build()?;
101-
let resp = configuration.client.execute(req).await?;
101+
let resp = configuration.client.execute(req)?;
102102

103103
let status = resp.status();
104104

105105
if !status.is_client_error() && !status.is_server_error() {
106106
Ok(resp)
107107
} else {
108-
let content = resp.text().await?;
108+
let content = resp.text()?;
109109
let entity: Option<TestsFileResponseGetError> = serde_json::from_str(&content).ok();
110110
Err(Error::ResponseError(ResponseContent { status, content, entity }))
111111
}
112112
}
113113

114114
/// Tests inline enum query parameters
115-
pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result<Vec<models::ModelWithInlineEnum>, Error<TestsInlineEnumBoxingGetError>> {
115+
pub fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result<Vec<models::ModelWithInlineEnum>, Error<TestsInlineEnumBoxingGetError>> {
116116
// add a prefix to parameters to efficiently prevent name collisions
117117
let p_query_status = status;
118118

@@ -127,7 +127,7 @@ pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configu
127127
}
128128

129129
let req = req_builder.build()?;
130-
let resp = configuration.client.execute(req).await?;
130+
let resp = configuration.client.execute(req)?;
131131

132132
let status = resp.status();
133133
let content_type = resp
@@ -138,21 +138,21 @@ pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configu
138138
let content_type = super::ContentType::from(content_type);
139139

140140
if !status.is_client_error() && !status.is_server_error() {
141-
let content = resp.text().await?;
141+
let content = resp.text()?;
142142
match content_type {
143143
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
144144
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ModelWithInlineEnum&gt;`"))),
145145
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ModelWithInlineEnum&gt;`")))),
146146
}
147147
} else {
148-
let content = resp.text().await?;
148+
let content = resp.text()?;
149149
let entity: Option<TestsInlineEnumBoxingGetError> = serde_json::from_str(&content).ok();
150150
Err(Error::ResponseError(ResponseContent { status, content, entity }))
151151
}
152152
}
153153

154154
/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors
155-
pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, model_with_inline_enum: models::ModelWithInlineEnum) -> Result<models::ModelWithInlineEnum, Error<TestsInlineEnumBoxingPostError>> {
155+
pub fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, model_with_inline_enum: models::ModelWithInlineEnum) -> Result<models::ModelWithInlineEnum, Error<TestsInlineEnumBoxingPostError>> {
156156
// add a prefix to parameters to efficiently prevent name collisions
157157
let p_body_model_with_inline_enum = model_with_inline_enum;
158158

@@ -165,7 +165,7 @@ pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Config
165165
req_builder = req_builder.json(&p_body_model_with_inline_enum);
166166

167167
let req = req_builder.build()?;
168-
let resp = configuration.client.execute(req).await?;
168+
let resp = configuration.client.execute(req)?;
169169

170170
let status = resp.status();
171171
let content_type = resp
@@ -176,20 +176,20 @@ pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Config
176176
let content_type = super::ContentType::from(content_type);
177177

178178
if !status.is_client_error() && !status.is_server_error() {
179-
let content = resp.text().await?;
179+
let content = resp.text()?;
180180
match content_type {
181181
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
182182
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModelWithInlineEnum`"))),
183183
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModelWithInlineEnum`")))),
184184
}
185185
} else {
186-
let content = resp.text().await?;
186+
let content = resp.text()?;
187187
let entity: Option<TestsInlineEnumBoxingPostError> = serde_json::from_str(&content).ok();
188188
Err(Error::ResponseError(ResponseContent { status, content, entity }))
189189
}
190190
}
191191

192-
pub async fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result<models::TypeTesting, Error<TestsTypeTestingGetError>> {
192+
pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result<models::TypeTesting, Error<TestsTypeTestingGetError>> {
193193

194194
let uri_str = format!("{}/tests/typeTesting", configuration.base_path);
195195
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
@@ -199,7 +199,7 @@ pub async fn tests_type_testing_get(configuration: &configuration::Configuration
199199
}
200200

201201
let req = req_builder.build()?;
202-
let resp = configuration.client.execute(req).await?;
202+
let resp = configuration.client.execute(req)?;
203203

204204
let status = resp.status();
205205
let content_type = resp
@@ -210,14 +210,14 @@ pub async fn tests_type_testing_get(configuration: &configuration::Configuration
210210
let content_type = super::ContentType::from(content_type);
211211

212212
if !status.is_client_error() && !status.is_server_error() {
213-
let content = resp.text().await?;
213+
let content = resp.text()?;
214214
match content_type {
215215
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
216216
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TypeTesting`"))),
217217
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TypeTesting`")))),
218218
}
219219
} else {
220-
let content = resp.text().await?;
220+
let content = resp.text()?;
221221
let entity: Option<TestsTypeTestingGetError> = serde_json::from_str(&content).ok();
222222
Err(Error::ResponseError(ResponseContent { status, content, entity }))
223223
}

0 commit comments

Comments
 (0)