From ffe9efe18dbe8955303800ae085b068da75da17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Fri, 29 Nov 2024 12:29:23 +0100 Subject: [PATCH] update rust samples --- .../src/apis/default_api.rs | 31 +- .../src/apis/default_api.rs | 27 +- .../composed-oneof/src/apis/default_api.rs | 60 ++- .../emptyObject/src/apis/default_api.rs | 31 +- .../oneOf-array-map/src/apis/default_api.rs | 60 ++- .../oneOf-reuseRef/src/apis/default_api.rs | 31 +- .../rust/reqwest/oneOf/src/apis/bar_api.rs | 33 +- .../rust/reqwest/oneOf/src/apis/foo_api.rs | 64 ++- .../reqwest/name-mapping/src/apis/fake_api.rs | 37 +- .../src/apis/fake_api.rs | 50 +-- .../src/apis/pet_api.rs | 389 +++++++---------- .../src/apis/store_api.rs | 165 +++---- .../src/apis/testing_api.rs | 69 ++- .../src/apis/user_api.rs | 389 +++++++---------- .../src/apis/fake_api.rs | 50 +-- .../src/apis/pet_api.rs | 381 +++++++---------- .../src/apis/store_api.rs | 157 +++---- .../src/apis/testing_api.rs | 69 ++- .../src/apis/user_api.rs | 341 ++++++--------- .../petstore-async/src/apis/fake_api.rs | 50 +-- .../petstore-async/src/apis/pet_api.rs | 389 +++++++---------- .../petstore-async/src/apis/store_api.rs | 165 +++---- .../petstore-async/src/apis/testing_api.rs | 69 ++- .../petstore-async/src/apis/user_api.rs | 389 +++++++---------- .../petstore-avoid-box/src/apis/fake_api.rs | 50 +-- .../petstore-avoid-box/src/apis/pet_api.rs | 389 +++++++---------- .../petstore-avoid-box/src/apis/store_api.rs | 165 +++---- .../src/apis/testing_api.rs | 69 ++- .../petstore-avoid-box/src/apis/user_api.rs | 389 +++++++---------- .../src/apis/fake_api.rs | 35 +- .../src/apis/pet_api.rs | 404 ++++++++---------- .../src/apis/store_api.rs | 144 +++---- .../src/apis/testing_api.rs | 60 ++- .../src/apis/user_api.rs | 368 +++++++--------- .../src/apis/fake_api.rs | 35 +- .../src/apis/pet_api.rs | 324 ++++++-------- .../src/apis/store_api.rs | 134 +++--- .../src/apis/testing_api.rs | 60 ++- .../src/apis/user_api.rs | 308 ++++++------- .../reqwest/petstore/src/apis/fake_api.rs | 35 +- .../rust/reqwest/petstore/src/apis/pet_api.rs | 324 ++++++-------- .../reqwest/petstore/src/apis/store_api.rs | 134 +++--- .../reqwest/petstore/src/apis/testing_api.rs | 60 ++- .../reqwest/petstore/src/apis/user_api.rs | 308 ++++++------- 44 files changed, 2975 insertions(+), 4316 deletions(-) diff --git a/samples/client/others/rust/reqwest-regression-16119/src/apis/default_api.rs b/samples/client/others/rust/reqwest-regression-16119/src/apis/default_api.rs index bea5f638a6e7..aea2ae866af3 100644 --- a/samples/client/others/rust/reqwest-regression-16119/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest-regression-16119/src/apis/default_api.rs @@ -24,30 +24,25 @@ pub enum ReproError { pub fn repro(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/repro", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/repro", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/default_api.rs b/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/default_api.rs index 179f9ea5c141..b356672ab850 100644 --- a/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/default_api.rs @@ -24,29 +24,24 @@ pub enum DemoColorGetError { pub async fn demo_color_get(configuration: &configuration::Configuration, color: models::Color) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/demo/{color}", configuration.base_path, color=color.to_string()); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/demo/{color}", local_var_configuration.base_path, color=color.to_string()); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/apis/default_api.rs b/samples/client/others/rust/reqwest/composed-oneof/src/apis/default_api.rs index c0def694ddee..f9de0fa88cce 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/apis/default_api.rs @@ -31,58 +31,48 @@ pub enum GetStateError { pub fn create_state(configuration: &configuration::Configuration, create_state_request: models::CreateStateRequest) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/state", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/state", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&create_state_request); + req_builder = req_builder.json(&create_state_request); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub fn get_state(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/state", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/state", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/emptyObject/src/apis/default_api.rs b/samples/client/others/rust/reqwest/emptyObject/src/apis/default_api.rs index 54b21d9c0766..395dc66a2885 100644 --- a/samples/client/others/rust/reqwest/emptyObject/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest/emptyObject/src/apis/default_api.rs @@ -24,30 +24,25 @@ pub enum EndpointGetError { pub fn endpoint_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/endpoint", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/endpoint", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/default_api.rs b/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/default_api.rs index 9fc93a60045b..e07093f1466b 100644 --- a/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/default_api.rs @@ -31,58 +31,48 @@ pub enum TestError { pub fn root_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub fn test(configuration: &configuration::Configuration, body: Option) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&body); + req_builder = req_builder.json(&body); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/default_api.rs b/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/default_api.rs index 3287c9177b3e..9d33512a11c7 100644 --- a/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/default_api.rs @@ -24,30 +24,25 @@ pub enum GetFruitError { pub fn get_fruit(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/example", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/example", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/apis/bar_api.rs b/samples/client/others/rust/reqwest/oneOf/src/apis/bar_api.rs index fc6b75d5ebcd..7081567ac187 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/apis/bar_api.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/apis/bar_api.rs @@ -24,31 +24,26 @@ pub enum CreateBarError { pub fn create_bar(configuration: &configuration::Configuration, bar_create: models::BarCreate) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/bar", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/bar", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&bar_create); + req_builder = req_builder.json(&bar_create); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/apis/foo_api.rs b/samples/client/others/rust/reqwest/oneOf/src/apis/foo_api.rs index cdcd1feaf2a5..b0d768776ba3 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/apis/foo_api.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/apis/foo_api.rs @@ -31,59 +31,49 @@ pub enum GetAllFoosError { pub fn create_foo(configuration: &configuration::Configuration, foo: Option) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/foo", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/foo", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&foo); + req_builder = req_builder.json(&foo); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub fn get_all_foos(configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/foo", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/foo", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs index 1dd40a13d980..338b9498b8e2 100644 --- a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs @@ -24,34 +24,29 @@ pub enum GetParameterNameMappingError { pub fn get_parameter_name_mapping(configuration: &configuration::Configuration, underscore_type: i64, r#type: &str, type_with_underscore: &str, dash_type: &str, http_debug_option: &str) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/parameter-name-mapping", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/parameter-name-mapping", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = local_var_req_builder.query(&[("type", &r#type.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("http_debug_option", &http_debug_option.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("type", &r#type.to_string())]); + req_builder = req_builder.query(&[("http_debug_option", &http_debug_option.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.header("_type", underscore_type.to_string()); - local_var_req_builder = local_var_req_builder.header("type_", type_with_underscore.to_string()); - local_var_req_builder = local_var_req_builder.header("-type", dash_type.to_string()); + req_builder = req_builder.header("_type", underscore_type.to_string()); + req_builder = req_builder.header("type_", type_with_underscore.to_string()); + req_builder = req_builder.header("-type", dash_type.to_string()); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/fake_api.rs index f93b447840da..ab939079a7c3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/fake_api.rs @@ -46,45 +46,33 @@ pub enum TestNullableRequiredParamError { /// pub async fn test_nullable_required_param(configuration: &configuration::Configuration, params: TestNullableRequiredParamParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - let dummy_required_nullable_param = params.dummy_required_nullable_param; - let uppercase = params.uppercase; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + match params.dummy_required_nullable_param { + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = params.uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs index 471556f03bd7..a17d641fac7b 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs @@ -211,342 +211,257 @@ pub enum UploadFileError { /// pub async fn add_pet(configuration: &configuration::Configuration, params: AddPetParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn delete_pet(configuration: &configuration::Configuration, params: DeletePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let api_key = params.api_key; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = params.api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub async fn find_pets_by_status(configuration: &configuration::Configuration, params: FindPetsByStatusParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", ¶ms.status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let tags = params.tags; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", ¶ms.tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: GetPetByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet(configuration: &configuration::Configuration, params: UpdatePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet_with_form(configuration: &configuration::Configuration, params: UpdatePetWithFormParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - let name = params.name; - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = params.name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = params.status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn upload_file(configuration: &configuration::Configuration, params: UploadFileParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let additional_metadata = params.additional_metadata; - let file = params.file; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form = reqwest::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + let mut multipart_form = reqwest::multipart::Form::new(); + if let Some(param_value) = params.additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } // TODO: support file upload for 'file' parameter - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/store_api.rs index 340e6f2dc97c..472c76a3fc5c 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/store_api.rs @@ -103,149 +103,110 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub async fn delete_order(configuration: &configuration::Configuration, params: DeleteOrderParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(params.order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub async fn get_inventory(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub async fn get_order_by_id(configuration: &configuration::Configuration, params: GetOrderByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=params.order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn place_order(configuration: &configuration::Configuration, params: PlaceOrderParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let order = params.order; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&order); + req_builder = req_builder.json(¶ms.order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs index 0dafccec4b72..1d61a0e17367 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs @@ -47,65 +47,48 @@ pub enum TestsTypeTestingGetError { pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/user_api.rs index 985f3b65e317..b3a34c064df0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/user_api.rs @@ -196,336 +196,255 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_array_input(configuration: &configuration::Configuration, params: CreateUsersWithArrayInputParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_list_input(configuration: &configuration::Configuration, params: CreateUsersWithListInputParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn get_user_by_name(configuration: &configuration::Configuration, params: GetUserByNameParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn login_user(configuration: &configuration::Configuration, params: LoginUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let password = params.password; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", ¶ms.username.to_string())]); + req_builder = req_builder.query(&[("password", ¶ms.password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn logout_user(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs index f93b447840da..ab939079a7c3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs @@ -46,45 +46,33 @@ pub enum TestNullableRequiredParamError { /// pub async fn test_nullable_required_param(configuration: &configuration::Configuration, params: TestNullableRequiredParamParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - let dummy_required_nullable_param = params.dummy_required_nullable_param; - let uppercase = params.uppercase; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + match params.dummy_required_nullable_param { + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = params.uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs index 55fffa82b61a..dde288bf2b3d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs @@ -211,353 +211,268 @@ pub enum UploadFileError { /// pub async fn add_pet(configuration: &configuration::Configuration, params: AddPetParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn delete_pet(configuration: &configuration::Configuration, params: DeletePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let api_key = params.api_key; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = params.api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub async fn find_pets_by_status(configuration: &configuration::Configuration, params: FindPetsByStatusParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", ¶ms.status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let tags = params.tags; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", ¶ms.tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: GetPetByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet(configuration: &configuration::Configuration, params: UpdatePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet_with_form(configuration: &configuration::Configuration, params: UpdatePetWithFormParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - let name = params.name; - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = params.name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = params.status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn upload_file(configuration: &configuration::Configuration, params: UploadFileParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let additional_metadata = params.additional_metadata; - let file = params.file; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - let mut local_var_form = reqwest::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + let mut multipart_form = reqwest::multipart::Form::new(); + if let Some(param_value) = params.additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } // TODO: support file upload for 'file' parameter - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs index ef3f71dbb9cf..4c9b99ae218d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs @@ -103,146 +103,107 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub async fn delete_order(configuration: &configuration::Configuration, params: DeleteOrderParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(params.order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub async fn get_inventory(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub async fn get_order_by_id(configuration: &configuration::Configuration, params: GetOrderByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=params.order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn place_order(configuration: &configuration::Configuration, params: PlaceOrderParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let order = params.order; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&order); + req_builder = req_builder.json(¶ms.order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs index 0dafccec4b72..1d61a0e17367 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs @@ -47,65 +47,48 @@ pub enum TestsTypeTestingGetError { pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs index b5b830ac64a1..b7e91fc6b36d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs @@ -196,318 +196,237 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_array_input(configuration: &configuration::Configuration, params: CreateUsersWithArrayInputParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_list_input(configuration: &configuration::Configuration, params: CreateUsersWithListInputParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn get_user_by_name(configuration: &configuration::Configuration, params: GetUserByNameParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn login_user(configuration: &configuration::Configuration, params: LoginUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let password = params.password; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", ¶ms.username.to_string())]); + req_builder = req_builder.query(&[("password", ¶ms.password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn logout_user(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } // Obtain a token from source provider. // Tokens can be Id or access tokens depending on the provider type and configuration. - let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + let token = configuration.token_source.token().await.map_err(Error::TokenSource)?; // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. - local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.header(reqwest::header::AUTHORIZATION, token); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs index f93b447840da..ab939079a7c3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/fake_api.rs @@ -46,45 +46,33 @@ pub enum TestNullableRequiredParamError { /// pub async fn test_nullable_required_param(configuration: &configuration::Configuration, params: TestNullableRequiredParamParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - let dummy_required_nullable_param = params.dummy_required_nullable_param; - let uppercase = params.uppercase; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + match params.dummy_required_nullable_param { + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = params.uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs index 471556f03bd7..a17d641fac7b 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs @@ -211,342 +211,257 @@ pub enum UploadFileError { /// pub async fn add_pet(configuration: &configuration::Configuration, params: AddPetParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn delete_pet(configuration: &configuration::Configuration, params: DeletePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let api_key = params.api_key; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = params.api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub async fn find_pets_by_status(configuration: &configuration::Configuration, params: FindPetsByStatusParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", ¶ms.status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let tags = params.tags; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", ¶ms.tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: GetPetByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet(configuration: &configuration::Configuration, params: UpdatePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet_with_form(configuration: &configuration::Configuration, params: UpdatePetWithFormParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - let name = params.name; - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = params.name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = params.status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn upload_file(configuration: &configuration::Configuration, params: UploadFileParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let additional_metadata = params.additional_metadata; - let file = params.file; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form = reqwest::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + let mut multipart_form = reqwest::multipart::Form::new(); + if let Some(param_value) = params.additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } // TODO: support file upload for 'file' parameter - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs index 340e6f2dc97c..472c76a3fc5c 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/store_api.rs @@ -103,149 +103,110 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub async fn delete_order(configuration: &configuration::Configuration, params: DeleteOrderParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(params.order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub async fn get_inventory(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub async fn get_order_by_id(configuration: &configuration::Configuration, params: GetOrderByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=params.order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn place_order(configuration: &configuration::Configuration, params: PlaceOrderParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let order = params.order; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&order); + req_builder = req_builder.json(¶ms.order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs index 0dafccec4b72..1d61a0e17367 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs @@ -47,65 +47,48 @@ pub enum TestsTypeTestingGetError { pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs index 985f3b65e317..b3a34c064df0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/user_api.rs @@ -196,336 +196,255 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_array_input(configuration: &configuration::Configuration, params: CreateUsersWithArrayInputParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_list_input(configuration: &configuration::Configuration, params: CreateUsersWithListInputParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn get_user_by_name(configuration: &configuration::Configuration, params: GetUserByNameParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn login_user(configuration: &configuration::Configuration, params: LoginUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let password = params.password; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", ¶ms.username.to_string())]); + req_builder = req_builder.query(&[("password", ¶ms.password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn logout_user(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/fake_api.rs index f93b447840da..ab939079a7c3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/fake_api.rs @@ -46,45 +46,33 @@ pub enum TestNullableRequiredParamError { /// pub async fn test_nullable_required_param(configuration: &configuration::Configuration, params: TestNullableRequiredParamParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - let dummy_required_nullable_param = params.dummy_required_nullable_param; - let uppercase = params.uppercase; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + match params.dummy_required_nullable_param { + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = params.uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs index 471556f03bd7..a17d641fac7b 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs @@ -211,342 +211,257 @@ pub enum UploadFileError { /// pub async fn add_pet(configuration: &configuration::Configuration, params: AddPetParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn delete_pet(configuration: &configuration::Configuration, params: DeletePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let api_key = params.api_key; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = params.api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub async fn find_pets_by_status(configuration: &configuration::Configuration, params: FindPetsByStatusParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", ¶ms.status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let tags = params.tags; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(¶ms.tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", ¶ms.tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: GetPetByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet(configuration: &configuration::Configuration, params: UpdatePetParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet = params.pet; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(¶ms.pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn update_pet_with_form(configuration: &configuration::Configuration, params: UpdatePetWithFormParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let pet_id = params.pet_id; - let name = params.name; - let status = params.status; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = params.name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = params.status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn upload_file(configuration: &configuration::Configuration, params: UploadFileParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let pet_id = params.pet_id; - let additional_metadata = params.additional_metadata; - let file = params.file; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=params.pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form = reqwest::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + let mut multipart_form = reqwest::multipart::Form::new(); + if let Some(param_value) = params.additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } // TODO: support file upload for 'file' parameter - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/store_api.rs index 340e6f2dc97c..472c76a3fc5c 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/store_api.rs @@ -103,149 +103,110 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub async fn delete_order(configuration: &configuration::Configuration, params: DeleteOrderParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(params.order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub async fn get_inventory(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub async fn get_order_by_id(configuration: &configuration::Configuration, params: GetOrderByIdParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=params.order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let order_id = params.order_id; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn place_order(configuration: &configuration::Configuration, params: PlaceOrderParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let order = params.order; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&order); + req_builder = req_builder.json(¶ms.order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs index 0dafccec4b72..1d61a0e17367 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs @@ -47,65 +47,48 @@ pub enum TestsTypeTestingGetError { pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/user_api.rs index 985f3b65e317..b3a34c064df0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/user_api.rs @@ -196,336 +196,255 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_array_input(configuration: &configuration::Configuration, params: CreateUsersWithArrayInputParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn create_users_with_list_input(configuration: &configuration::Configuration, params: CreateUsersWithListInputParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - // unbox the parameters - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn get_user_by_name(configuration: &configuration::Configuration, params: GetUserByNameParams) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - let username = params.username; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn login_user(configuration: &configuration::Configuration, params: LoginUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let password = params.password; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", ¶ms.username.to_string())]); + req_builder = req_builder.query(&[("password", ¶ms.password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub async fn logout_user(configuration: &configuration::Configuration) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - // unbox the parameters - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result, Error> { - let local_var_configuration = configuration; - - // unbox the parameters - let username = params.username; - let user = params.user; - - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(params.username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(¶ms.user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) } else { - let local_var_content = local_var_resp.text().await?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs index 24339cb769aa..80ca8f680fa8 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/fake_api.rs @@ -27,36 +27,31 @@ pub enum TestNullableRequiredParamError { /// pub fn test_nullable_required_param(configuration: &configuration::Configuration, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/pet_api.rs index 3bd8113f7bde..454fd8e2f0d3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/pet_api.rs @@ -84,393 +84,353 @@ pub enum UploadFileError { /// pub fn add_pet(configuration: &configuration::Configuration, pet: models::Pet) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "POST", &serde_json::to_string(&pet).expect("param should serialize to string"), ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(&pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "DELETE", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "GET", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "GET", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "GET", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn update_pet(configuration: &configuration::Configuration, pet: models::Pet) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "PUT", &serde_json::to_string(&pet).expect("param should serialize to string"), ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(&pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "POST", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "POST", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form = reqwest::blocking::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + let mut multipart_form = reqwest::blocking::multipart::Form::new(); + if let Some(param_value) = additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } - if let Some(local_var_param_value) = file { - local_var_form = local_var_form.file("file", local_var_param_value)?; + if let Some(param_value) = file { + multipart_form = multipart_form.file("file", param_value)?; } - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/store_api.rs index d1ad7c4a4fc6..0fb6597bed74 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/store_api.rs @@ -51,138 +51,118 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "GET", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn place_order(configuration: &configuration::Configuration, order: models::Order) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&order); + req_builder = req_builder.json(&order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs index 634576260d6a..d12d5ce0f29f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs @@ -31,57 +31,47 @@ pub enum TestsTypeTestingGetError { pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/user_api.rs index 3c186de94f98..c255e450cbc3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/user_api.rs @@ -85,359 +85,319 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub fn create_user(configuration: &configuration::Configuration, user: models::User) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "POST", &serde_json::to_string(&user).expect("param should serialize to string"), ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn create_users_with_array_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "POST", &serde_json::to_string(&user).expect("param should serialize to string"), ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn create_users_with_list_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "POST", &serde_json::to_string(&user).expect("param should serialize to string"), ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "DELETE", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", &username.to_string())]); + req_builder = req_builder.query(&[("password", &password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "GET", "", ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub fn update_user(configuration: &configuration::Configuration, username: &str, user: models::User) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key { - let local_var_new_headers = match local_var_aws_v4_key.sign( - &local_var_uri_str, + if let Some(ref aws_v4_key) = configuration.aws_v4_key { + let new_headers = match aws_v4_key.sign( + &uri_str, "PUT", &serde_json::to_string(&user).expect("param should serialize to string"), ) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; - for (local_var_name, local_var_value) in local_var_new_headers.iter() { - local_var_req_builder = local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str()); + for (name, value) in new_headers.iter() { + req_builder = req_builder.header(name.as_str(), value.as_str()); } } - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs index 24339cb769aa..80ca8f680fa8 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/fake_api.rs @@ -27,36 +27,31 @@ pub enum TestNullableRequiredParamError { /// pub fn test_nullable_required_param(configuration: &configuration::Configuration, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs index b16d781edcf8..3ed984d37078 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/pet_api.rs @@ -84,289 +84,249 @@ pub enum UploadFileError { /// pub fn add_pet(configuration: &configuration::Configuration, foo_pet: models::FooPet) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&foo_pet); + req_builder = req_builder.json(&foo_pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn update_pet(configuration: &configuration::Configuration, foo_pet: models::FooPet) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&foo_pet); + req_builder = req_builder.json(&foo_pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form = reqwest::blocking::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + let mut multipart_form = reqwest::blocking::multipart::Form::new(); + if let Some(param_value) = additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } - if let Some(local_var_param_value) = file { - local_var_form = local_var_form.file("file", local_var_param_value)?; + if let Some(param_value) = file { + multipart_form = multipart_form.file("file", param_value)?; } - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs index 6bce786967c4..17ca8a0e903e 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/store_api.rs @@ -51,125 +51,105 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn place_order(configuration: &configuration::Configuration, foo_order: models::FooOrder) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&foo_order); + req_builder = req_builder.json(&foo_order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs index 1b22593cdab6..c50f91a17e83 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs @@ -31,57 +31,47 @@ pub enum TestsTypeTestingGetError { pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs index dbb0bf2ff5ff..7c942ceda333 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/user_api.rs @@ -85,281 +85,241 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub fn create_user(configuration: &configuration::Configuration, foo_user: models::FooUser) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&foo_user); + req_builder = req_builder.json(&foo_user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn create_users_with_array_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn create_users_with_list_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", &username.to_string())]); + req_builder = req_builder.query(&[("password", &password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub fn update_user(configuration: &configuration::Configuration, username: &str, foo_user: models::FooUser) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&foo_user); + req_builder = req_builder.json(&foo_user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/fake_api.rs index 24339cb769aa..80ca8f680fa8 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/fake_api.rs @@ -27,36 +27,31 @@ pub enum TestNullableRequiredParamError { /// pub fn test_nullable_required_param(configuration: &configuration::Configuration, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/fake/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } match dummy_required_nullable_param { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, - None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, } - if let Some(local_var_param_value) = uppercase { - local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + if let Some(param_value) = uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs index a08c09aaa3cc..64f71cc80534 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs @@ -84,289 +84,249 @@ pub enum UploadFileError { /// pub fn add_pet(configuration: &configuration::Configuration, pet: models::Pet) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(&pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(local_var_param_value) = api_key { - local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + if let Some(param_value) = api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple status values can be provided with comma separated strings pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = match "csv" { - "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), - _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + req_builder = match "csv" { + "multi" => req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), }; - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a single pet pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn update_pet(configuration: &configuration::Configuration, pet: models::Pet) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - local_var_req_builder = local_var_req_builder.json(&pet); + req_builder = req_builder.json(&pet); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form_params = std::collections::HashMap::new(); - if let Some(local_var_param_value) = name { - local_var_form_params.insert("name", local_var_param_value.to_string()); + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = name { + multipart_form_params.insert("name", param_value.to_string()); } - if let Some(local_var_param_value) = status { - local_var_form_params.insert("status", local_var_param_value.to_string()); + if let Some(param_value) = status { + multipart_form_params.insert("status", param_value.to_string()); } - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + req_builder = req_builder.form(&multipart_form_params); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); }; - let mut local_var_form = reqwest::blocking::multipart::Form::new(); - if let Some(local_var_param_value) = additional_metadata { - local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + let mut multipart_form = reqwest::blocking::multipart::Form::new(); + if let Some(param_value) = additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } - if let Some(local_var_param_value) = file { - local_var_form = local_var_form.file("file", local_var_param_value)?; + if let Some(param_value) = file { + multipart_form = multipart_form.file("file", param_value)?; } - local_var_req_builder = local_var_req_builder.multipart(local_var_form); + req_builder = req_builder.multipart(multipart_form); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs index e62feebbf8d9..ff1d9f240523 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs @@ -51,125 +51,105 @@ pub enum PlaceOrderError { /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// Returns a map of status codes to quantities pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn place_order(configuration: &configuration::Configuration, order: models::Order) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - local_var_req_builder = local_var_req_builder.json(&order); + req_builder = req_builder.json(&order); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs index 634576260d6a..d12d5ce0f29f 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs @@ -31,57 +31,47 @@ pub enum TestsTypeTestingGetError { pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(local_var_resp) + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs index 40505efb17f2..2c480480654b 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs @@ -85,281 +85,241 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub fn create_user(configuration: &configuration::Configuration, user: models::User) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn create_users_with_array_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn create_users_with_list_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); - local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + req_builder = req_builder.query(&[("username", &username.to_string())]); + req_builder = req_builder.query(&[("password", &password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - let local_var_content = local_var_resp.text()?; - serde_json::from_str(&local_var_content).map_err(Error::from) + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + serde_json::from_str(&content).map_err(Error::from) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { - let local_var_configuration = configuration; + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } } /// This can only be done by the logged in user. pub fn update_user(configuration: &configuration::Configuration, username: &str, user: models::User) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, }; - local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); + req_builder = req_builder.header("api_key", value); }; - local_var_req_builder = local_var_req_builder.json(&user); + req_builder = req_builder.json(&user); - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req)?; + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; - let local_var_status = local_var_resp.status(); + let status = resp.status(); - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + if !status.is_client_error() && !status.is_server_error() { Ok(()) } else { - let local_var_content = local_var_resp.text()?; - let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) } }