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 4e7c63fe5ccf..f63ece5c942c 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -1,7 +1,7 @@ {{>partial_header}} #[allow(unused_imports)] use std::rc::Rc; -use std::borrow::Borrow; +{{^supportAsync}}use std::borrow::Borrow;{{/supportAsync}} use std::option::Option; use reqwest; @@ -49,10 +49,10 @@ pub trait {{{classname}}} { {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; + fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; {{/vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}} - fn {{{operationId}}}(&self, {{#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<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; + fn {{{operationId}}}(&self, {{#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<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; {{/vendorExtensions.x-group-parameters}} {{/operation}} {{/operations}} @@ -63,7 +63,7 @@ impl {{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - {{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + {{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { // unbox the parameters {{#allParams}} let {{paramName}} = params.{{paramName}}; @@ -71,7 +71,7 @@ impl {{{classname}}} for {{{classname}}}Client { {{/vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}} - {{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}, {{#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<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + {{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}, {{#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<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { {{/vendorExtensions.x-group-parameters}} {{^supportAsync}} let configuration: &configuration::Configuration = self.configuration.borrow(); @@ -263,7 +263,7 @@ impl {{{classname}}} for {{{classname}}}Client { {{/hasBodyParam}} let req = req_builder.build()?; - let mut resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?; + let {{^supportAsync}}mut {{/supportAsync}}resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?; if resp.status().is_success() { {{^returnType}} Ok(()) diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache index f9aba13baf9f..991df72e4e08 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache @@ -2,33 +2,33 @@ use reqwest; use serde_json; #[derive(Debug, Clone)] -pub struct ResponseErrorContent { +pub struct ResponseErrorContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseErrorContent), + ResponseError(ResponseErrorContent), } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs index e20a276940ae..d7a1750eb71a 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs @@ -31,11 +31,11 @@ impl DefaultApiClient { pub trait DefaultApi { - fn fileresponsetest(&self, ) -> Result; + fn fileresponsetest(&self, ) -> Result>; } impl DefaultApi for DefaultApiClient { - fn fileresponsetest(&self, ) -> Result { + fn fileresponsetest(&self, ) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs index 68e16d25dd77..d7bf6b5967d8 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs @@ -2,33 +2,33 @@ use reqwest; use serde_json; #[derive(Debug, Clone)] -pub struct ResponseErrorContent { +pub struct ResponseErrorContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseErrorContent), + ResponseError(ResponseErrorContent), } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs index d5094fdc85d9..a48a5cb9a3bd 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/mod.rs @@ -2,33 +2,33 @@ use reqwest; use serde_json; #[derive(Debug, Clone)] -pub struct ResponseErrorContent { +pub struct ResponseErrorContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseErrorContent), + ResponseError(ResponseErrorContent), } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } 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 7611ba5eb9bf..0a071213099e 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 @@ -10,7 +10,7 @@ #[allow(unused_imports)] use std::rc::Rc; -use std::borrow::Borrow; + use std::option::Option; use reqwest; @@ -18,7 +18,7 @@ use reqwest; use super::{Error, configuration}; - pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { + pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/pet", configuration.base_path); @@ -33,7 +33,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -45,7 +45,7 @@ use super::{Error, configuration}; } } - pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { + pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); @@ -62,7 +62,7 @@ use super::{Error, configuration}; }; let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -74,7 +74,7 @@ use super::{Error, configuration}; } } - pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { + pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec) -> Result, Error> { let client = &configuration.client; let uri_str = format!("{}/pet/findByStatus", configuration.base_path); @@ -89,7 +89,7 @@ use super::{Error, configuration}; }; let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::>().await?) } else { @@ -101,7 +101,7 @@ use super::{Error, configuration}; } } - pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { + pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { let client = &configuration.client; let uri_str = format!("{}/pet/findByTags", configuration.base_path); @@ -116,7 +116,7 @@ use super::{Error, configuration}; }; let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::>().await?) } else { @@ -128,7 +128,7 @@ use super::{Error, configuration}; } } - pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result { + pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result> { let client = &configuration.client; let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); @@ -147,7 +147,7 @@ use super::{Error, configuration}; }; let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::().await?) } else { @@ -159,7 +159,7 @@ use super::{Error, configuration}; } } - pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { + pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/pet", configuration.base_path); @@ -174,7 +174,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -186,7 +186,7 @@ use super::{Error, configuration}; } } - pub async fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { + pub async fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); @@ -208,7 +208,7 @@ use super::{Error, configuration}; req_builder = req_builder.form(&form_params); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -220,7 +220,7 @@ use super::{Error, configuration}; } } - pub async fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result { + pub async fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { let client = &configuration.client; let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); @@ -240,7 +240,7 @@ use super::{Error, configuration}; req_builder = req_builder.multipart(form); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::().await?) } else { 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 fd47da210aa7..84243ee179bc 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 @@ -10,7 +10,7 @@ #[allow(unused_imports)] use std::rc::Rc; -use std::borrow::Borrow; + use std::option::Option; use reqwest; @@ -18,7 +18,7 @@ use reqwest; use super::{Error, configuration}; - pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { + pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id)); @@ -29,7 +29,7 @@ use super::{Error, configuration}; } let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -41,7 +41,7 @@ use super::{Error, configuration}; } } - pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap, Error> { + pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap, Error> { let client = &configuration.client; let uri_str = format!("{}/store/inventory", configuration.base_path); @@ -60,7 +60,7 @@ use super::{Error, configuration}; }; let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::<::std::collections::HashMap>().await?) } else { @@ -72,7 +72,7 @@ use super::{Error, configuration}; } } - pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result { + pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result> { let client = &configuration.client; let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); @@ -83,7 +83,7 @@ use super::{Error, configuration}; } let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::().await?) } else { @@ -95,7 +95,7 @@ use super::{Error, configuration}; } } - pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result { + pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result> { let client = &configuration.client; let uri_str = format!("{}/store/order", configuration.base_path); @@ -107,7 +107,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::().await?) } else { 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 4f3c5b46cd94..e5d2f703750c 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 @@ -10,7 +10,7 @@ #[allow(unused_imports)] use std::rc::Rc; -use std::borrow::Borrow; + use std::option::Option; use reqwest; @@ -18,7 +18,7 @@ use reqwest; use super::{Error, configuration}; - pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error> { + pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/user", configuration.base_path); @@ -30,7 +30,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -42,7 +42,7 @@ use super::{Error, configuration}; } } - pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { + pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/user/createWithArray", configuration.base_path); @@ -54,7 +54,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -66,7 +66,7 @@ use super::{Error, configuration}; } } - pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { + pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/user/createWithList", configuration.base_path); @@ -78,7 +78,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -90,7 +90,7 @@ use super::{Error, configuration}; } } - pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { + pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); @@ -101,7 +101,7 @@ use super::{Error, configuration}; } let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -113,7 +113,7 @@ use super::{Error, configuration}; } } - pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result { + pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result> { let client = &configuration.client; let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); @@ -124,7 +124,7 @@ use super::{Error, configuration}; } let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::().await?) } else { @@ -136,7 +136,7 @@ use super::{Error, configuration}; } } - pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result { + pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result> { let client = &configuration.client; let uri_str = format!("{}/user/login", configuration.base_path); @@ -149,7 +149,7 @@ use super::{Error, configuration}; } let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(resp.json::().await?) } else { @@ -161,7 +161,7 @@ use super::{Error, configuration}; } } - pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { + pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/user/logout", configuration.base_path); @@ -172,7 +172,7 @@ use super::{Error, configuration}; } let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { @@ -184,7 +184,7 @@ use super::{Error, configuration}; } } - pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error> { + pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error> { let client = &configuration.client; let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username)); @@ -196,7 +196,7 @@ use super::{Error, configuration}; req_builder = req_builder.json(&body); let req = req_builder.build()?; - let mut resp = client.execute(req).await?; + let resp = client.execute(req).await?; if resp.status().is_success() { Ok(()) } else { diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs index 5951c1bdd81e..4f25e9c66608 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs @@ -2,33 +2,33 @@ use reqwest; use serde_json; #[derive(Debug, Clone)] -pub struct ResponseErrorContent { +pub struct ResponseErrorContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseErrorContent), + ResponseError(ResponseErrorContent), } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } 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 110aea402e92..f956d069827f 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 @@ -31,18 +31,18 @@ impl PetApiClient { pub trait PetApi { - fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error>; - fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error>; - fn find_pets_by_status(&self, status: Vec) -> Result, Error>; - fn find_pets_by_tags(&self, tags: Vec) -> Result, Error>; - fn get_pet_by_id(&self, pet_id: i64) -> Result; - fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error>; - fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error>; - fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result; + fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error>; + fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error>; + fn find_pets_by_status(&self, status: Vec) -> Result, Error>; + fn find_pets_by_tags(&self, tags: Vec) -> Result, Error>; + fn get_pet_by_id(&self, pet_id: i64) -> Result>; + fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error>; + fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error>; + fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result>; } impl PetApi for PetApiClient { - fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error> { + fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -70,7 +70,7 @@ impl PetApi for PetApiClient { } } - fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { + fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -100,7 +100,7 @@ impl PetApi for PetApiClient { } } - fn find_pets_by_status(&self, status: Vec) -> Result, Error> { + fn find_pets_by_status(&self, status: Vec) -> Result, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -128,7 +128,7 @@ impl PetApi for PetApiClient { } } - fn find_pets_by_tags(&self, tags: Vec) -> Result, Error> { + fn find_pets_by_tags(&self, tags: Vec) -> Result, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -156,7 +156,7 @@ impl PetApi for PetApiClient { } } - fn get_pet_by_id(&self, pet_id: i64) -> Result { + fn get_pet_by_id(&self, pet_id: i64) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -188,7 +188,7 @@ impl PetApi for PetApiClient { } } - fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error> { + fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -216,7 +216,7 @@ impl PetApi for PetApiClient { } } - fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { + fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -251,7 +251,7 @@ impl PetApi for PetApiClient { } } - fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result { + fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; 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 49f625c6e4ab..04bbf3d47711 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 @@ -31,14 +31,14 @@ impl StoreApiClient { pub trait StoreApi { - fn delete_order(&self, order_id: &str) -> Result<(), Error>; - fn get_inventory(&self, ) -> Result<::std::collections::HashMap, Error>; - fn get_order_by_id(&self, order_id: i64) -> Result; - fn place_order(&self, body: crate::models::Order) -> Result; + fn delete_order(&self, order_id: &str) -> Result<(), Error>; + fn get_inventory(&self, ) -> Result<::std::collections::HashMap, Error>; + fn get_order_by_id(&self, order_id: i64) -> Result>; + fn place_order(&self, body: crate::models::Order) -> Result>; } impl StoreApi for StoreApiClient { - fn delete_order(&self, order_id: &str) -> Result<(), Error> { + fn delete_order(&self, order_id: &str) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -62,7 +62,7 @@ impl StoreApi for StoreApiClient { } } - fn get_inventory(&self, ) -> Result<::std::collections::HashMap, Error> { + fn get_inventory(&self, ) -> Result<::std::collections::HashMap, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -94,7 +94,7 @@ impl StoreApi for StoreApiClient { } } - fn get_order_by_id(&self, order_id: i64) -> Result { + fn get_order_by_id(&self, order_id: i64) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -118,7 +118,7 @@ impl StoreApi for StoreApiClient { } } - fn place_order(&self, body: crate::models::Order) -> Result { + fn place_order(&self, body: crate::models::Order) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; 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 3bb552cd84a4..2e9d76c80e3d 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 @@ -31,18 +31,18 @@ impl UserApiClient { pub trait UserApi { - fn create_user(&self, body: crate::models::User) -> Result<(), Error>; - fn create_users_with_array_input(&self, body: Vec) -> Result<(), Error>; - fn create_users_with_list_input(&self, body: Vec) -> Result<(), Error>; - fn delete_user(&self, username: &str) -> Result<(), Error>; - fn get_user_by_name(&self, username: &str) -> Result; - fn login_user(&self, username: &str, password: &str) -> Result; - fn logout_user(&self, ) -> Result<(), Error>; - fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error>; + fn create_user(&self, body: crate::models::User) -> Result<(), Error>; + fn create_users_with_array_input(&self, body: Vec) -> Result<(), Error>; + fn create_users_with_list_input(&self, body: Vec) -> Result<(), Error>; + fn delete_user(&self, username: &str) -> Result<(), Error>; + fn get_user_by_name(&self, username: &str) -> Result>; + fn login_user(&self, username: &str, password: &str) -> Result>; + fn logout_user(&self, ) -> Result<(), Error>; + fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error>; } impl UserApi for UserApiClient { - fn create_user(&self, body: crate::models::User) -> Result<(), Error> { + fn create_user(&self, body: crate::models::User) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -67,7 +67,7 @@ impl UserApi for UserApiClient { } } - fn create_users_with_array_input(&self, body: Vec) -> Result<(), Error> { + fn create_users_with_array_input(&self, body: Vec) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -92,7 +92,7 @@ impl UserApi for UserApiClient { } } - fn create_users_with_list_input(&self, body: Vec) -> Result<(), Error> { + fn create_users_with_list_input(&self, body: Vec) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -117,7 +117,7 @@ impl UserApi for UserApiClient { } } - fn delete_user(&self, username: &str) -> Result<(), Error> { + fn delete_user(&self, username: &str) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -141,7 +141,7 @@ impl UserApi for UserApiClient { } } - fn get_user_by_name(&self, username: &str) -> Result { + fn get_user_by_name(&self, username: &str) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -165,7 +165,7 @@ impl UserApi for UserApiClient { } } - fn login_user(&self, username: &str, password: &str) -> Result { + fn login_user(&self, username: &str, password: &str) -> Result> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -191,7 +191,7 @@ impl UserApi for UserApiClient { } } - fn logout_user(&self, ) -> Result<(), Error> { + fn logout_user(&self, ) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -215,7 +215,7 @@ impl UserApi for UserApiClient { } } - fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error> { + fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs index e65d80b22720..24f19aa5a9c6 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs @@ -31,11 +31,11 @@ impl DefaultApiClient { pub trait DefaultApi { - fn dummy_get(&self, ) -> Result<(), Error>; + fn dummy_get(&self, ) -> Result<(), Error>; } impl DefaultApi for DefaultApiClient { - fn dummy_get(&self, ) -> Result<(), Error> { + fn dummy_get(&self, ) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs index 68e16d25dd77..d7bf6b5967d8 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/mod.rs @@ -2,33 +2,33 @@ use reqwest; use serde_json; #[derive(Debug, Clone)] -pub struct ResponseErrorContent { +pub struct ResponseErrorContent { pub status: reqwest::StatusCode, pub content: String, - pub entity: Option, + pub entity: Option, } #[derive(Debug)] -pub enum Error { +pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), - ResponseError(ResponseErrorContent), + ResponseError(ResponseErrorContent), } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) }