From 78be97ce7e26eecd4f35593438fac8e6d4839959 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 26 Aug 2020 15:51:52 +0800 Subject: [PATCH 1/2] use local_var prefix in rust variables --- .../main/resources/rust/reqwest/api.mustache | 132 +++---- .../petstore-async/src/apis/pet_api.rs | 328 +++++++++--------- .../petstore-async/src/apis/store_api.rs | 142 ++++---- .../petstore-async/src/apis/user_api.rs | 268 +++++++------- .../rust/reqwest/petstore/src/apis/pet_api.rs | 292 ++++++++-------- .../reqwest/petstore/src/apis/store_api.rs | 124 +++---- .../reqwest/petstore/src/apis/user_api.rs | 224 ++++++------ 7 files changed, 755 insertions(+), 755 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 62d63e1b9b14..933490b09b0e 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -91,18 +91,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> { {{/vendorExtensions.x-group-parameters}} - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}}); - let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str()); + let local_var_uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}}); + let mut local_var_req_builder = local_var_client.{{{httpMethod}}}(local_var_uri_str.as_str()); {{#queryParams}} {{#required}} - req_builder = req_builder.query(&[("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string())]); {{/required}} {{^required}} - if let Some(ref s) = {{{paramName}}} { - req_builder = req_builder.query(&[("{{{baseName}}}", &s{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string())]); + if let Some(ref local_var_str) = {{{paramName}}} { + local_var_req_builder = local_var_req_builder.query(&[("{{{baseName}}}", &local_var_str{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string())]); } {{/required}} {{/queryParams}} @@ -110,37 +110,37 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{#authMethods}} {{#isApiKey}} {{#isKeyInQuery}} - if let Some(ref apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, + if let Some(ref local_var_apikey) = 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, }; - req_builder = req_builder.query(&[("{{{keyParamName}}}", val)]); + local_var_req_builder = local_var_req_builder.query(&[("{{{keyParamName}}}", local_var_value)]); } {{/isKeyInQuery}} {{/isApiKey}} {{/authMethods}} {{/hasAuthMethods}} - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } {{#hasHeaderParams}} {{#headerParams}} {{#required}} {{^isNullable}} - req_builder = req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); {{/isNullable}} {{#isNullable}} match {{{paramName}}} { - Some(param_value) => { req_builder = req_builder.header("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); }, - None => { req_builder = req_builder.header("{{{baseName}}}", ""); }, + Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); }, + None => { local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", ""); }, } {{/isNullable}} {{/required}} {{^required}} - if let Some(param_value) = {{{paramName}}} { - req_builder = req_builder.header("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + if let Some(local_var_param_value) = {{{paramName}}} { + local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); } {{/required}} {{/headerParams}} @@ -149,55 +149,55 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{#authMethods}} {{#isApiKey}} {{#isKeyInHeader}} - if let Some(ref apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, + if let Some(ref local_var_apikey) = 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, }; - req_builder = req_builder.header("{{{keyParamName}}}", val); + local_var_req_builder = local_var_req_builder.header("{{{keyParamName}}}", local_var_value); }; {{/isKeyInHeader}} {{/isApiKey}} {{#isBasic}} {{#isBasicBasic}} - if let Some(ref auth_conf) = configuration.basic_auth { - req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned()); + if let Some(ref local_var_auth_conf) = configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); }; {{/isBasicBasic}} {{#isBasicBearer}} - if let Some(ref token) = configuration.bearer_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; {{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} - if let Some(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; {{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} {{#isMultipart}} {{#hasFormParams}} - let mut form = reqwest::multipart::Form::new(); + let mut local_var_form = reqwest::multipart::Form::new(); {{#formParams}} {{#isFile}} {{^supportAsync}} {{#required}} {{^isNullable}} - form = form.file("{{{baseName}}}", {{{paramName}}})?; + local_var_form = local_var_form.file("{{{baseName}}}", {{{paramName}}})?; {{/isNullable}} {{#isNullable}} match {{{paramName}}} { - Some(param_value) => { form = form.file("{{{baseName}}}", param_value)?; }, + Some(local_var_param_value) => { local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value)?; }, None => { unimplemented!("Required nullable form file param not supported"); }, } {{/isNullable}} {{/required}} {{^required}} - if let Some(param_value) = {{{paramName}}} { - form = form.file("{{{baseName}}}", param_value)?; + if let Some(local_var_param_value) = {{{paramName}}} { + local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value)?; } {{/required}} {{/supportAsync}} @@ -208,99 +208,99 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{^isFile}} {{#required}} {{^isNullable}} - form = form.text("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + local_var_form = local_var_form.text("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); {{/isNullable}} {{#isNullable}} match {{{paramName}}} { - Some(param_value) => { form = form.text("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); }, - None => { form = form.text("{{{baseName}}}", ""); }, + Some(local_var_param_value) => { form = form.text("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); }, + None => { local_var_form = local_var_form.text("{{{baseName}}}", ""); }, } {{/isNullable}} {{/required}} {{^required}} - if let Some(param_value) = {{{paramName}}} { - form = form.text("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + if let Some(local_var_param_value) = {{{paramName}}} { + local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); } {{/required}} {{/isFile}} {{/formParams}} - req_builder = req_builder.multipart(form); + local_var_req_builder = local_var_req_builder.multipart(form); {{/hasFormParams}} {{/isMultipart}} {{^isMultipart}} {{#hasFormParams}} - let mut form_params = std::collections::HashMap::new(); + let mut local_var_form_params = std::collections::HashMap::new(); {{#formParams}} {{#isFile}} {{#required}} {{^isNullable}} - form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); + local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); {{/isNullable}} {{#isNullable}} match {{{paramName}}} { - Some(param_value) => { form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); }, + Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); }, None => { unimplemented!("Required nullable file form param not supported with x-www-form-urlencoded content"); }, } {{/isNullable}} {{/required}} {{^required}} - if let Some(param_value) = {{{paramName}}} { - form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); + if let Some(local_var_param_value) = {{{paramName}}} { + local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); } {{/required}} {{/isFile}} {{^isFile}} {{#required}} {{^isNullable}} - form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + local_var_form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); {{/isNullable}} {{#isNullable}} match {{{paramName}}} { - Some(param_value) => { form_params.insert("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); }, - None => { form_params.insert("{{{baseName}}}", ""); }, + Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); }, + None => { local_var_form_params.insert("{{{baseName}}}", ""); }, } {{/isNullable}} {{/required}} {{^required}} - if let Some(param_value) = {{{paramName}}} { - form_params.insert("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + if let Some(local_var_param_value) = {{{paramName}}} { + local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); } {{/required}} {{/isFile}} {{/formParams}} - req_builder = req_builder.form(&form_params); + local_var_req_builder = local_var_req_builder.form(&local_var_form_params); {{/hasFormParams}} {{/isMultipart}} {{#hasBodyParam}} {{#bodyParams}} - req_builder = req_builder.json(&{{{paramName}}}); + local_var_req_builder = local_var_req_builder.json(&{{{paramName}}}); {{/bodyParams}} {{/hasBodyParam}} - let req = req_builder.build()?; - let {{^supportAsync}}mut {{/supportAsync}}resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?; + let local_var_req = local_var_req_builder.build()?; + let {{^supportAsync}}mut {{/supportAsync}}local_var_resp = local_var_client.execute(local_var_req){{#supportAsync}}.await{{/supportAsync}}?; - let status = resp.status(); - let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - if status.is_success() { + if local_var_status.is_success() { {{^supportMultipleResponses}} {{^returnType}} Ok(()) {{/returnType}} {{#returnType}} - serde_json::from_str(&content).map_err(Error::from) + serde_json::from_str(&local_var_content).map_err(Error::from) {{/returnType}} {{/supportMultipleResponses}} {{#supportMultipleResponses}} - let entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + let local_var_entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) {{/supportMultipleResponses}} } else { - let entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } 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 d2d1b7c37a94..52b42c57d844 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 @@ -212,33 +212,33 @@ pub async fn add_pet(configuration: &configuration::Configuration, params: AddPe let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - req_builder = req_builder.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -248,35 +248,35 @@ pub async fn delete_pet(configuration: &configuration::Configuration, params: De let api_key = params.api_key; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); - let mut req_builder = client.delete(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - if let Some(param_value) = api_key { - req_builder = req_builder.header("api_key", param_value.to_string()); + 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(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -286,33 +286,33 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p let status = params.status; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/findByStatus", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").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.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + if let Some(ref local_var_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -322,33 +322,33 @@ pub async fn find_pets_by_tags(configuration: &configuration::Configuration, par let tags = params.tags; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/findByTags", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").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.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + if let Some(ref local_var_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -358,37 +358,37 @@ pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: let pet_id = params.pet_id; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = 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 apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, + if let Some(ref local_var_apikey) = 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, }; - req_builder = req_builder.header("api_key", val); + local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); }; - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -397,33 +397,33 @@ pub async fn update_pet(configuration: &configuration::Configuration, params: Up let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet", configuration.base_path); - let mut req_builder = client.put(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet", configuration.base_path); + let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - req_builder = req_builder.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -434,40 +434,40 @@ pub async fn update_pet_with_form(configuration: &configuration::Configuration, let status = params.status; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let mut form_params = std::collections::HashMap::new(); - if let Some(param_value) = name { - form_params.insert("name", param_value.to_string()); + 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()); } - if let Some(param_value) = status { - form_params.insert("status", param_value.to_string()); + if let Some(local_var_param_value) = status { + local_var_form_params.insert("status", local_var_param_value.to_string()); } - req_builder = req_builder.form(&form_params); + local_var_req_builder = local_var_req_builder.form(&local_var_form_params); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -478,38 +478,38 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U let file = params.file; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let mut form = reqwest::multipart::Form::new(); - if let Some(param_value) = additional_metadata { - form = form.text("additionalMetadata", param_value.to_string()); + 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()); } // TODO: support file upload for 'file' parameter - req_builder = req_builder.multipart(form); + local_var_req_builder = local_var_req_builder.multipart(form); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } 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 52f40c9ad5c2..a3847b76193e 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 @@ -107,29 +107,29 @@ pub async fn delete_order(configuration: &configuration::Configuration, params: let order_id = params.order_id; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut req_builder = client.delete(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -138,37 +138,37 @@ pub async fn get_inventory(configuration: &configuration::Configuration) -> Resu // unbox the parameters - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/inventory", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/inventory", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = 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 apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, + if let Some(ref local_var_apikey) = 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, }; - req_builder = req_builder.header("api_key", val); + local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); }; - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -178,29 +178,29 @@ pub async fn get_order_by_id(configuration: &configuration::Configuration, param let order_id = params.order_id; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -209,30 +209,30 @@ pub async fn place_order(configuration: &configuration::Configuration, params: P let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/order", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/order", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } 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 6678d1ec8d0e..181e8db722aa 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 @@ -200,30 +200,30 @@ pub async fn create_user(configuration: &configuration::Configuration, params: C let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/user", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -232,30 +232,30 @@ pub async fn create_users_with_array_input(configuration: &configuration::Config let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/createWithArray", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -264,30 +264,30 @@ pub async fn create_users_with_list_input(configuration: &configuration::Configu let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/createWithList", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -297,29 +297,29 @@ pub async fn delete_user(configuration: &configuration::Configuration, params: D let username = params.username; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); - let mut req_builder = client.delete(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -328,29 +328,29 @@ pub async fn get_user_by_name(configuration: &configuration::Configuration, para let username = params.username; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -360,31 +360,31 @@ pub async fn login_user(configuration: &configuration::Configuration, params: Lo let password = params.password; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/login", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/login", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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()); + 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) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -392,29 +392,29 @@ pub async fn logout_user(configuration: &configuration::Configuration) -> Result // unbox the parameters - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/logout", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/logout", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } @@ -425,30 +425,30 @@ pub async fn update_user(configuration: &configuration::Configuration, params: U let body = params.body; - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); - let mut req_builder = client.put(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let resp = client.execute(req).await?; + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; - let status = resp.status(); - let content = resp.text().await?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; - if status.is_success() { - let entity: Option = serde_json::from_str(&content).ok(); - let result = ResponseContent { status, content, entity }; - Ok(result) + if local_var_status.is_success() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Ok(local_var_result) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } 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 c6715740fc47..31df97621223 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,264 +84,264 @@ pub enum UploadFileError { pub fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - req_builder = req_builder.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); - let mut req_builder = client.delete(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - if let Some(param_value) = api_key { - req_builder = req_builder.header("api_key", param_value.to_string()); + 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(ref token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// Multiple status values can be provided with comma separated strings pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/findByStatus", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").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.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + if let Some(ref local_var_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// 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 client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/findByTags", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").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.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + if let Some(ref local_var_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// Returns a single pet pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = 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 apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, + if let Some(ref local_var_apikey) = 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, }; - req_builder = req_builder.header("api_key", val); + local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); }; - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet", configuration.base_path); - let mut req_builder = client.put(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet", configuration.base_path); + let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - req_builder = req_builder.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let mut form_params = std::collections::HashMap::new(); - if let Some(param_value) = name { - form_params.insert("name", param_value.to_string()); + 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()); } - if let Some(param_value) = status { - form_params.insert("status", param_value.to_string()); + if let Some(local_var_param_value) = status { + local_var_form_params.insert("status", local_var_param_value.to_string()); } - req_builder = req_builder.form(&form_params); + local_var_req_builder = local_var_req_builder.form(&local_var_form_params); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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 token) = configuration.oauth_access_token { - req_builder = req_builder.bearer_auth(token.to_owned()); + if let Some(ref local_var_token) = configuration.oauth_access_token { + local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); }; - let mut form = reqwest::multipart::Form::new(); - if let Some(param_value) = additional_metadata { - form = form.text("additionalMetadata", param_value.to_string()); + 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()); } - if let Some(param_value) = file { - form = form.file("file", param_value)?; + if let Some(local_var_param_value) = file { + local_var_form = local_var_form.file("file", local_var_param_value)?; } - req_builder = req_builder.multipart(form); + local_var_req_builder = local_var_req_builder.multipart(form); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } 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 2474d591dbc1..4a3b71bf777f 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 @@ -52,116 +52,116 @@ 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 client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); - let mut req_builder = client.delete(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// Returns a map of status codes to quantities pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap, Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/inventory", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/inventory", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = 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 apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, + if let Some(ref local_var_apikey) = 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, }; - req_builder = req_builder.header("api_key", val); + local_var_req_builder = local_var_req_builder.header("api_key", local_var_value); }; - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/store/order", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/store/order", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } 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 de5fc2cc4f4e..5ea71aef32e7 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 @@ -86,217 +86,217 @@ pub enum UpdateUserError { /// This can only be done by the logged in user. pub fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/user", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/createWithArray", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/createWithList", configuration.base_path); - let mut req_builder = client.post(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// This can only be done by the logged in user. pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); - let mut req_builder = client.delete(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/login", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/login", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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()); + 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) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { - serde_json::from_str(&content).map_err(Error::from) + if local_var_status.is_success() { + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/logout", configuration.base_path); - let mut req_builder = client.get(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/logout", configuration.base_path); + let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str()); - 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_user_agent) = configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } /// This can only be done by the logged in user. pub fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error> { - let client = &configuration.client; + let local_var_client = &configuration.client; - let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); - let mut req_builder = client.put(uri_str.as_str()); + let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str()); - 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_user_agent) = 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.json(&body); + local_var_req_builder = local_var_req_builder.json(&body); - let req = req_builder.build()?; - let mut resp = client.execute(req)?; + let local_var_req = local_var_req_builder.build()?; + let mut local_var_resp = local_var_client.execute(local_var_req)?; - let status = resp.status(); - let content = resp.text()?; + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text()?; - if status.is_success() { + if local_var_status.is_success() { Ok(()) } else { - let entity: Option = serde_json::from_str(&content).ok(); - let error = ResponseContent { status, content, entity }; - Err(Error::ResponseError(error)) + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + Err(Error::ResponseError(local_var_error)) } } From f03d78b62e6a5c54fd0e13f1e43c6a634fe9792f Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 26 Aug 2020 16:26:54 +0800 Subject: [PATCH 2/2] minor fixes --- .../main/resources/rust/reqwest/api.mustache | 8 ++-- .../rust-reqwest/.openapi-generator/VERSION | 1 - .../petstore-async/src/apis/pet_api.rs | 48 +++++++++---------- .../petstore-async/src/apis/store_api.rs | 16 +++---- .../petstore-async/src/apis/user_api.rs | 32 ++++++------- .../rust/reqwest/petstore/src/apis/pet_api.rs | 32 ++++++------- .../reqwest/petstore/src/apis/store_api.rs | 8 ++-- .../reqwest/petstore/src/apis/user_api.rs | 16 +++---- 8 files changed, 80 insertions(+), 81 deletions(-) delete mode 100644 samples/client/petstore/rust-reqwest/.openapi-generator/VERSION diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 933490b09b0e..fe924ddce19b 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -173,7 +173,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{/isBasic}} {{#isOAuth}} if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; {{/isOAuth}} {{/authMethods}} @@ -224,7 +224,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{/required}} {{/isFile}} {{/formParams}} - local_var_req_builder = local_var_req_builder.multipart(form); + local_var_req_builder = local_var_req_builder.multipart(local_var_form); {{/hasFormParams}} {{/isMultipart}} {{^isMultipart}} @@ -294,12 +294,12 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{/supportMultipleResponses}} {{#supportMultipleResponses}} let local_var_entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) {{/supportMultipleResponses}} } else { let local_var_entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } diff --git a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION b/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION deleted file mode 100644 index 479c313e87b9..000000000000 --- a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -4.0.3-SNAPSHOT \ No newline at end of file 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 52b42c57d844..20644907820c 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 @@ -221,7 +221,7 @@ pub async fn add_pet(configuration: &configuration::Configuration, params: AddPe local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; local_var_req_builder = local_var_req_builder.json(&body); @@ -233,11 +233,11 @@ pub async fn add_pet(configuration: &configuration::Configuration, params: AddPe if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -260,7 +260,7 @@ pub async fn delete_pet(configuration: &configuration::Configuration, params: De local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let local_var_req = local_var_req_builder.build()?; @@ -271,11 +271,11 @@ pub async fn delete_pet(configuration: &configuration::Configuration, params: De if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -296,7 +296,7 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let local_var_req = local_var_req_builder.build()?; @@ -307,11 +307,11 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -332,7 +332,7 @@ pub async fn find_pets_by_tags(configuration: &configuration::Configuration, par local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let local_var_req = local_var_req_builder.build()?; @@ -343,11 +343,11 @@ pub async fn find_pets_by_tags(configuration: &configuration::Configuration, par if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -383,11 +383,11 @@ pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -406,7 +406,7 @@ pub async fn update_pet(configuration: &configuration::Configuration, params: Up local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; local_var_req_builder = local_var_req_builder.json(&body); @@ -418,11 +418,11 @@ pub async fn update_pet(configuration: &configuration::Configuration, params: Up if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -443,7 +443,7 @@ pub async fn update_pet_with_form(configuration: &configuration::Configuration, local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let mut local_var_form_params = std::collections::HashMap::new(); if let Some(local_var_param_value) = name { @@ -462,11 +462,11 @@ pub async fn update_pet_with_form(configuration: &configuration::Configuration, if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -487,14 +487,14 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_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()); } // TODO: support file upload for 'file' parameter - local_var_req_builder = local_var_req_builder.multipart(form); + local_var_req_builder = local_var_req_builder.multipart(local_var_form); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -504,11 +504,11 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } 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 a3847b76193e..df70cd424958 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 @@ -124,11 +124,11 @@ pub async fn delete_order(configuration: &configuration::Configuration, params: if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -163,11 +163,11 @@ pub async fn get_inventory(configuration: &configuration::Configuration) -> Resu if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -195,11 +195,11 @@ pub async fn get_order_by_id(configuration: &configuration::Configuration, param if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -227,11 +227,11 @@ pub async fn place_order(configuration: &configuration::Configuration, params: P if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } 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 181e8db722aa..7a0375ba9b14 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 @@ -218,11 +218,11 @@ pub async fn create_user(configuration: &configuration::Configuration, params: C if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -250,11 +250,11 @@ pub async fn create_users_with_array_input(configuration: &configuration::Config if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -282,11 +282,11 @@ pub async fn create_users_with_list_input(configuration: &configuration::Configu if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -314,11 +314,11 @@ pub async fn delete_user(configuration: &configuration::Configuration, params: D if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -345,11 +345,11 @@ pub async fn get_user_by_name(configuration: &configuration::Configuration, para if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -379,11 +379,11 @@ pub async fn login_user(configuration: &configuration::Configuration, params: Lo if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -409,11 +409,11 @@ pub async fn logout_user(configuration: &configuration::Configuration) -> Result if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -443,11 +443,11 @@ pub async fn update_user(configuration: &configuration::Configuration, params: U if local_var_status.is_success() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } 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 31df97621223..301943aa6351 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 @@ -93,7 +93,7 @@ pub fn add_pet(configuration: &configuration::Configuration, body: crate::models local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; local_var_req_builder = local_var_req_builder.json(&body); @@ -107,7 +107,7 @@ pub fn add_pet(configuration: &configuration::Configuration, body: crate::models Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -126,7 +126,7 @@ pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let local_var_req = local_var_req_builder.build()?; @@ -139,7 +139,7 @@ pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -157,7 +157,7 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status: local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let local_var_req = local_var_req_builder.build()?; @@ -170,7 +170,7 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status: serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -188,7 +188,7 @@ pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let local_var_req = local_var_req_builder.build()?; @@ -201,7 +201,7 @@ pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -236,7 +236,7 @@ pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -252,7 +252,7 @@ pub fn update_pet(configuration: &configuration::Configuration, body: crate::mod local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; local_var_req_builder = local_var_req_builder.json(&body); @@ -266,7 +266,7 @@ pub fn update_pet(configuration: &configuration::Configuration, body: crate::mod Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -282,7 +282,7 @@ pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let mut local_var_form_params = std::collections::HashMap::new(); if let Some(local_var_param_value) = name { @@ -303,7 +303,7 @@ pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -319,7 +319,7 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = req_builder.bearer_auth(local_var_token.to_owned()); + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; let mut local_var_form = reqwest::multipart::Form::new(); if let Some(local_var_param_value) = additional_metadata { @@ -328,7 +328,7 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad if let Some(local_var_param_value) = file { local_var_form = local_var_form.file("file", local_var_param_value)?; } - local_var_req_builder = local_var_req_builder.multipart(form); + local_var_req_builder = local_var_req_builder.multipart(local_var_form); let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; @@ -340,7 +340,7 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } 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 4a3b71bf777f..f7f9fa87b1e0 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 @@ -71,7 +71,7 @@ pub fn delete_order(configuration: &configuration::Configuration, order_id: &str Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -106,7 +106,7 @@ pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<: serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -133,7 +133,7 @@ pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -160,7 +160,7 @@ pub fn place_order(configuration: &configuration::Configuration, body: crate::mo serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } 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 5ea71aef32e7..4aaf235f8ee9 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 @@ -106,7 +106,7 @@ pub fn create_user(configuration: &configuration::Configuration, body: crate::mo Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -133,7 +133,7 @@ pub fn create_users_with_array_input(configuration: &configuration::Configuratio Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -160,7 +160,7 @@ pub fn create_users_with_list_input(configuration: &configuration::Configuration Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -187,7 +187,7 @@ pub fn delete_user(configuration: &configuration::Configuration, username: &str) Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -213,7 +213,7 @@ pub fn get_user_by_name(configuration: &configuration::Configuration, username: serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -241,7 +241,7 @@ pub fn login_user(configuration: &configuration::Configuration, username: &str, serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -267,7 +267,7 @@ pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } @@ -295,7 +295,7 @@ pub fn update_user(configuration: &configuration::Configuration, username: &str, Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { local_var_status, local_var_content, local_var_entity }; + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } }