Skip to content

Commit ab87592

Browse files
committed
update rust samples
1 parent 46f1379 commit ab87592

File tree

44 files changed

+3192
-4186
lines changed

Some content is hidden

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

44 files changed

+3192
-4186
lines changed

samples/client/others/rust/reqwest-regression-16119/src/apis/default_api.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,27 @@ pub enum ReproError {
2424

2525

2626
pub fn repro(configuration: &configuration::Configuration, ) -> Result<models::Parent, Error<ReproError>> {
27-
let local_var_configuration = configuration;
27+
// add a prefix to parameters to efficiently prevent name collisions
2828

29-
let local_var_client = &local_var_configuration.client;
29+
let uri_str = format!("{}/repro", configuration.base_path);
30+
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3031

31-
let local_var_uri_str = format!("{}/repro", local_var_configuration.base_path);
32-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
33-
34-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
35-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
32+
if let Some(ref user_agent) = configuration.user_agent {
33+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3634
}
3735

38-
let local_var_req = local_var_req_builder.build()?;
39-
let local_var_resp = local_var_client.execute(local_var_req)?;
36+
let req = req_builder.build()?;
37+
let resp = configuration.client.execute(req)?;
4038

41-
let local_var_status = local_var_resp.status();
39+
let status = resp.status();
4240

43-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
44-
let local_var_content = local_var_resp.text()?;
45-
serde_json::from_str(&local_var_content).map_err(Error::from)
41+
if !status.is_client_error() && !status.is_server_error() {
42+
let content = resp.text()?;
43+
serde_json::from_str(&content).map_err(Error::from)
4644
} else {
47-
let local_var_content = local_var_resp.text()?;
48-
let local_var_entity: Option<ReproError> = serde_json::from_str(&local_var_content).ok();
49-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50-
Err(Error::ResponseError(local_var_error))
45+
let content = resp.text()?;
46+
let entity: Option<ReproError> = serde_json::from_str(&content).ok();
47+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
5148
}
5249
}
5350

samples/client/others/rust/reqwest/api-with-ref-param/src/apis/default_api.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,27 @@ pub enum DemoColorGetError {
2424

2525

2626
pub async fn demo_color_get(configuration: &configuration::Configuration, color: models::Color) -> Result<(), Error<DemoColorGetError>> {
27-
let local_var_configuration = configuration;
27+
// add a prefix to parameters to efficiently prevent name collisions
28+
let p_color = color;
2829

29-
let local_var_client = &local_var_configuration.client;
30+
let uri_str = format!("{}/demo/{color}", configuration.base_path, color=p_color.to_string());
31+
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3032

31-
let local_var_uri_str = format!("{}/demo/{color}", local_var_configuration.base_path, color=color.to_string());
32-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
33-
34-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
35-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
33+
if let Some(ref user_agent) = configuration.user_agent {
34+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3635
}
3736

38-
let local_var_req = local_var_req_builder.build()?;
39-
let local_var_resp = local_var_client.execute(local_var_req).await?;
37+
let req = req_builder.build()?;
38+
let resp = configuration.client.execute(req).await?;
4039

41-
let local_var_status = local_var_resp.status();
40+
let status = resp.status();
4241

43-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
42+
if !status.is_client_error() && !status.is_server_error() {
4443
Ok(())
4544
} else {
46-
let local_var_content = local_var_resp.text().await?;
47-
let local_var_entity: Option<DemoColorGetError> = serde_json::from_str(&local_var_content).ok();
48-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
49-
Err(Error::ResponseError(local_var_error))
45+
let content = resp.text().await?;
46+
let entity: Option<DemoColorGetError> = serde_json::from_str(&content).ok();
47+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
5048
}
5149
}
5250

samples/client/others/rust/reqwest/composed-oneof/src/apis/default_api.rs

+28-33
Original file line numberDiff line numberDiff line change
@@ -31,58 +31,53 @@ pub enum GetStateError {
3131

3232

3333
pub fn create_state(configuration: &configuration::Configuration, create_state_request: models::CreateStateRequest) -> Result<(), Error<CreateStateError>> {
34-
let local_var_configuration = configuration;
34+
// add a prefix to parameters to efficiently prevent name collisions
35+
let p_create_state_request = create_state_request;
3536

36-
let local_var_client = &local_var_configuration.client;
37+
let uri_str = format!("{}/state", configuration.base_path);
38+
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3739

38-
let local_var_uri_str = format!("{}/state", local_var_configuration.base_path);
39-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
40-
41-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
42-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
40+
if let Some(ref user_agent) = configuration.user_agent {
41+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4342
}
44-
local_var_req_builder = local_var_req_builder.json(&create_state_request);
43+
req_builder = req_builder.json(&p_create_state_request);
4544

46-
let local_var_req = local_var_req_builder.build()?;
47-
let local_var_resp = local_var_client.execute(local_var_req)?;
45+
let req = req_builder.build()?;
46+
let resp = configuration.client.execute(req)?;
4847

49-
let local_var_status = local_var_resp.status();
48+
let status = resp.status();
5049

51-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
50+
if !status.is_client_error() && !status.is_server_error() {
5251
Ok(())
5352
} else {
54-
let local_var_content = local_var_resp.text()?;
55-
let local_var_entity: Option<CreateStateError> = serde_json::from_str(&local_var_content).ok();
56-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
57-
Err(Error::ResponseError(local_var_error))
53+
let content = resp.text()?;
54+
let entity: Option<CreateStateError> = serde_json::from_str(&content).ok();
55+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
5856
}
5957
}
6058

6159
pub fn get_state(configuration: &configuration::Configuration, ) -> Result<models::GetState200Response, Error<GetStateError>> {
62-
let local_var_configuration = configuration;
63-
64-
let local_var_client = &local_var_configuration.client;
60+
// add a prefix to parameters to efficiently prevent name collisions
6561

66-
let local_var_uri_str = format!("{}/state", local_var_configuration.base_path);
67-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
62+
let uri_str = format!("{}/state", configuration.base_path);
63+
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6864

69-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
70-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
65+
if let Some(ref user_agent) = configuration.user_agent {
66+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7167
}
7268

73-
let local_var_req = local_var_req_builder.build()?;
74-
let local_var_resp = local_var_client.execute(local_var_req)?;
69+
let req = req_builder.build()?;
70+
let resp = configuration.client.execute(req)?;
7571

76-
let local_var_status = local_var_resp.status();
72+
let status = resp.status();
7773

78-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
79-
let local_var_content = local_var_resp.text()?;
80-
serde_json::from_str(&local_var_content).map_err(Error::from)
74+
if !status.is_client_error() && !status.is_server_error() {
75+
let content = resp.text()?;
76+
serde_json::from_str(&content).map_err(Error::from)
8177
} else {
82-
let local_var_content = local_var_resp.text()?;
83-
let local_var_entity: Option<GetStateError> = serde_json::from_str(&local_var_content).ok();
84-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
85-
Err(Error::ResponseError(local_var_error))
78+
let content = resp.text()?;
79+
let entity: Option<GetStateError> = serde_json::from_str(&content).ok();
80+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
8681
}
8782
}
8883

samples/client/others/rust/reqwest/emptyObject/src/apis/default_api.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,27 @@ pub enum EndpointGetError {
2424

2525

2626
pub fn endpoint_get(configuration: &configuration::Configuration, ) -> Result<models::EmptyObject, Error<EndpointGetError>> {
27-
let local_var_configuration = configuration;
27+
// add a prefix to parameters to efficiently prevent name collisions
2828

29-
let local_var_client = &local_var_configuration.client;
29+
let uri_str = format!("{}/endpoint", configuration.base_path);
30+
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3031

31-
let local_var_uri_str = format!("{}/endpoint", local_var_configuration.base_path);
32-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
33-
34-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
35-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
32+
if let Some(ref user_agent) = configuration.user_agent {
33+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3634
}
3735

38-
let local_var_req = local_var_req_builder.build()?;
39-
let local_var_resp = local_var_client.execute(local_var_req)?;
36+
let req = req_builder.build()?;
37+
let resp = configuration.client.execute(req)?;
4038

41-
let local_var_status = local_var_resp.status();
39+
let status = resp.status();
4240

43-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
44-
let local_var_content = local_var_resp.text()?;
45-
serde_json::from_str(&local_var_content).map_err(Error::from)
41+
if !status.is_client_error() && !status.is_server_error() {
42+
let content = resp.text()?;
43+
serde_json::from_str(&content).map_err(Error::from)
4644
} else {
47-
let local_var_content = local_var_resp.text()?;
48-
let local_var_entity: Option<EndpointGetError> = serde_json::from_str(&local_var_content).ok();
49-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50-
Err(Error::ResponseError(local_var_error))
45+
let content = resp.text()?;
46+
let entity: Option<EndpointGetError> = serde_json::from_str(&content).ok();
47+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
5148
}
5249
}
5350

samples/client/others/rust/reqwest/oneOf-array-map/src/apis/default_api.rs

+28-33
Original file line numberDiff line numberDiff line change
@@ -31,58 +31,53 @@ pub enum TestError {
3131

3232

3333
pub fn root_get(configuration: &configuration::Configuration, ) -> Result<models::Fruit, Error<RootGetError>> {
34-
let local_var_configuration = configuration;
34+
// add a prefix to parameters to efficiently prevent name collisions
3535

36-
let local_var_client = &local_var_configuration.client;
36+
let uri_str = format!("{}/", configuration.base_path);
37+
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3738

38-
let local_var_uri_str = format!("{}/", local_var_configuration.base_path);
39-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
40-
41-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
42-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
39+
if let Some(ref user_agent) = configuration.user_agent {
40+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4341
}
4442

45-
let local_var_req = local_var_req_builder.build()?;
46-
let local_var_resp = local_var_client.execute(local_var_req)?;
43+
let req = req_builder.build()?;
44+
let resp = configuration.client.execute(req)?;
4745

48-
let local_var_status = local_var_resp.status();
46+
let status = resp.status();
4947

50-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
51-
let local_var_content = local_var_resp.text()?;
52-
serde_json::from_str(&local_var_content).map_err(Error::from)
48+
if !status.is_client_error() && !status.is_server_error() {
49+
let content = resp.text()?;
50+
serde_json::from_str(&content).map_err(Error::from)
5351
} else {
54-
let local_var_content = local_var_resp.text()?;
55-
let local_var_entity: Option<RootGetError> = serde_json::from_str(&local_var_content).ok();
56-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
57-
Err(Error::ResponseError(local_var_error))
52+
let content = resp.text()?;
53+
let entity: Option<RootGetError> = serde_json::from_str(&content).ok();
54+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
5855
}
5956
}
6057

6158
pub fn test(configuration: &configuration::Configuration, body: Option<serde_json::Value>) -> Result<(), Error<TestError>> {
62-
let local_var_configuration = configuration;
63-
64-
let local_var_client = &local_var_configuration.client;
59+
// add a prefix to parameters to efficiently prevent name collisions
60+
let p_body = body;
6561

66-
let local_var_uri_str = format!("{}/", local_var_configuration.base_path);
67-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
62+
let uri_str = format!("{}/", configuration.base_path);
63+
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6864

69-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
70-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
65+
if let Some(ref user_agent) = configuration.user_agent {
66+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7167
}
72-
local_var_req_builder = local_var_req_builder.json(&body);
68+
req_builder = req_builder.json(&p_body);
7369

74-
let local_var_req = local_var_req_builder.build()?;
75-
let local_var_resp = local_var_client.execute(local_var_req)?;
70+
let req = req_builder.build()?;
71+
let resp = configuration.client.execute(req)?;
7672

77-
let local_var_status = local_var_resp.status();
73+
let status = resp.status();
7874

79-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
75+
if !status.is_client_error() && !status.is_server_error() {
8076
Ok(())
8177
} else {
82-
let local_var_content = local_var_resp.text()?;
83-
let local_var_entity: Option<TestError> = serde_json::from_str(&local_var_content).ok();
84-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
85-
Err(Error::ResponseError(local_var_error))
78+
let content = resp.text()?;
79+
let entity: Option<TestError> = serde_json::from_str(&content).ok();
80+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
8681
}
8782
}
8883

samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/default_api.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,27 @@ pub enum GetFruitError {
2424

2525

2626
pub fn get_fruit(configuration: &configuration::Configuration, ) -> Result<models::Fruit, Error<GetFruitError>> {
27-
let local_var_configuration = configuration;
27+
// add a prefix to parameters to efficiently prevent name collisions
2828

29-
let local_var_client = &local_var_configuration.client;
29+
let uri_str = format!("{}/example", configuration.base_path);
30+
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3031

31-
let local_var_uri_str = format!("{}/example", local_var_configuration.base_path);
32-
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
33-
34-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
35-
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
32+
if let Some(ref user_agent) = configuration.user_agent {
33+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3634
}
3735

38-
let local_var_req = local_var_req_builder.build()?;
39-
let local_var_resp = local_var_client.execute(local_var_req)?;
36+
let req = req_builder.build()?;
37+
let resp = configuration.client.execute(req)?;
4038

41-
let local_var_status = local_var_resp.status();
39+
let status = resp.status();
4240

43-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
44-
let local_var_content = local_var_resp.text()?;
45-
serde_json::from_str(&local_var_content).map_err(Error::from)
41+
if !status.is_client_error() && !status.is_server_error() {
42+
let content = resp.text()?;
43+
serde_json::from_str(&content).map_err(Error::from)
4644
} else {
47-
let local_var_content = local_var_resp.text()?;
48-
let local_var_entity: Option<GetFruitError> = serde_json::from_str(&local_var_content).ok();
49-
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50-
Err(Error::ResponseError(local_var_error))
45+
let content = resp.text()?;
46+
let entity: Option<GetFruitError> = serde_json::from_str(&content).ok();
47+
Err(Error::ResponseError(ResponseContent { status, content, entity }))
5148
}
5249
}
5350

0 commit comments

Comments
 (0)