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 54a1518f85b..977f0b6edbc 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -283,7 +283,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { {{^supportMultipleResponses}} {{^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 5bf951361d9..e4daf80c8f6 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 @@ -1,5 +1,3 @@ -use reqwest; -use serde_json; use std::error; use std::fmt; 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 181305dc4fe..c24f345edf3 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 @@ -1,5 +1,3 @@ -use reqwest; -use serde_json; use std::error; use std::fmt; 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 20644907820..e4162a33129 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 @@ -231,7 +231,7 @@ pub async fn add_pet(configuration: &configuration::Configuration, params: AddPe let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -269,7 +269,7 @@ pub async fn delete_pet(configuration: &configuration::Configuration, params: De let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -305,7 +305,7 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -341,7 +341,7 @@ pub async fn find_pets_by_tags(configuration: &configuration::Configuration, par let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -381,7 +381,7 @@ pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -416,7 +416,7 @@ pub async fn update_pet(configuration: &configuration::Configuration, params: Up let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -460,7 +460,7 @@ pub async fn update_pet_with_form(configuration: &configuration::Configuration, let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -502,7 +502,7 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) 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 df70cd42495..21647faa062 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 @@ -122,7 +122,7 @@ pub async fn delete_order(configuration: &configuration::Configuration, params: let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -161,7 +161,7 @@ pub async fn get_inventory(configuration: &configuration::Configuration) -> Resu let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -193,7 +193,7 @@ pub async fn get_order_by_id(configuration: &configuration::Configuration, param let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -225,7 +225,7 @@ pub async fn place_order(configuration: &configuration::Configuration, params: P let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) 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 7a0375ba9b1..a791bfbc9bb 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 @@ -216,7 +216,7 @@ pub async fn create_user(configuration: &configuration::Configuration, params: C let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -248,7 +248,7 @@ pub async fn create_users_with_array_input(configuration: &configuration::Config let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -280,7 +280,7 @@ pub async fn create_users_with_list_input(configuration: &configuration::Configu let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -312,7 +312,7 @@ pub async fn delete_user(configuration: &configuration::Configuration, params: D let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -343,7 +343,7 @@ pub async fn get_user_by_name(configuration: &configuration::Configuration, para let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -377,7 +377,7 @@ pub async fn login_user(configuration: &configuration::Configuration, params: Lo let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -407,7 +407,7 @@ pub async fn logout_user(configuration: &configuration::Configuration) -> Result let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) @@ -441,7 +441,7 @@ pub async fn update_user(configuration: &configuration::Configuration, params: U let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text().await?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Ok(local_var_result) 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 181305dc4fe..c24f345edf3 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/mod.rs @@ -1,5 +1,3 @@ -use reqwest; -use serde_json; use std::error; use std::fmt; 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 301943aa635..47cf47f1d59 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 @@ -103,7 +103,7 @@ pub fn add_pet(configuration: &configuration::Configuration, body: crate::models let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -135,7 +135,7 @@ pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -166,7 +166,7 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status: let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -197,7 +197,7 @@ pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -232,7 +232,7 @@ pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -262,7 +262,7 @@ pub fn update_pet(configuration: &configuration::Configuration, body: crate::mod let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -299,7 +299,7 @@ pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -336,7 +336,7 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); 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 f7f9fa87b1e..898599f9b2f 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 @@ -67,7 +67,7 @@ pub fn delete_order(configuration: &configuration::Configuration, order_id: &str let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -102,7 +102,7 @@ pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<: let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -129,7 +129,7 @@ pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -156,7 +156,7 @@ pub fn place_order(configuration: &configuration::Configuration, body: crate::mo let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); 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 4aaf235f8ee..97f0f3c4e14 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 @@ -102,7 +102,7 @@ pub fn create_user(configuration: &configuration::Configuration, body: crate::mo let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -129,7 +129,7 @@ pub fn create_users_with_array_input(configuration: &configuration::Configuratio let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -156,7 +156,7 @@ pub fn create_users_with_list_input(configuration: &configuration::Configuration let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -183,7 +183,7 @@ pub fn delete_user(configuration: &configuration::Configuration, username: &str) let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -209,7 +209,7 @@ pub fn get_user_by_name(configuration: &configuration::Configuration, username: let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -237,7 +237,7 @@ pub fn login_user(configuration: &configuration::Configuration, username: &str, let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 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(); @@ -263,7 +263,7 @@ pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -291,7 +291,7 @@ pub fn update_user(configuration: &configuration::Configuration, username: &str, let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; - if local_var_status.is_success() { + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok();