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 f63ece5c942..319595bf2f2 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -44,15 +44,28 @@ pub struct {{{operationIdCamelCase}}}Params { {{/operation}} {{/operations}} +{{#operations}} +{{#operation}} +/// struct for typed errors of method `{{operationId}}` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum {{{operationIdCamelCase}}}Errors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +{{/operation}} +{{/operations}} + {{^supportAsync}} 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<{{{operationIdCamelCase}}}Errors>>; {{/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<{{{operationIdCamelCase}}}Errors>>; {{/vendorExtensions.x-group-parameters}} {{/operation}} {{/operations}} @@ -63,7 +76,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<{{{operationIdCamelCase}}}Errors>> { // unbox the parameters {{#allParams}} let {{paramName}} = params.{{paramName}}; @@ -71,7 +84,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<{{{operationIdCamelCase}}}Errors>> { {{/vendorExtensions.x-group-parameters}} {{^supportAsync}} let configuration: &configuration::Configuration = self.configuration.borrow(); @@ -274,7 +287,7 @@ impl {{{classname}}} for {{{classname}}}Client { } else { let status = resp.status(); let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option<{{{operationIdCamelCase}}}Errors> = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } 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 d7a1750eb71..1207f6f22b0 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 @@ -30,12 +30,21 @@ impl DefaultApiClient { } +/// struct for typed errors of method `fileresponsetest` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum FileresponsetestErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + 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; @@ -53,7 +62,7 @@ impl DefaultApi for DefaultApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(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 0a071213099..8f3a4e34215 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 @@ -18,7 +18,72 @@ use reqwest; use super::{Error, configuration}; - pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error> { +/// struct for typed errors of method `add_pet` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddPetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `delete_pet` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeletePetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `find_pets_by_status` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByStatusErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `find_pets_by_tags` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByTagsErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_pet_by_id` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPetByIdErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `update_pet` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `update_pet_with_form` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetWithFormErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `upload_file` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadFileErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + + 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); @@ -39,13 +104,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -68,13 +133,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -95,13 +160,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -122,13 +187,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -153,13 +218,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -180,13 +245,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -214,13 +279,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -246,7 +311,7 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(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 84243ee179b..63d998a77e9 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 @@ -18,7 +18,40 @@ use reqwest; use super::{Error, configuration}; - pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { +/// struct for typed errors of method `delete_order` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_inventory` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInventoryErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_order_by_id` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByIdErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `place_order` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlaceOrderErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + + 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)); @@ -35,13 +68,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -66,13 +99,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -89,13 +122,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -113,7 +146,7 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(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 e5d2f703750..60ac0015377 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 @@ -18,7 +18,72 @@ use reqwest; use super::{Error, configuration}; - pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error> { +/// struct for typed errors of method `create_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `create_users_with_array_input` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithArrayInputErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `create_users_with_list_input` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithListInputErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `delete_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_user_by_name` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByNameErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `login_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum LoginUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `logout_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum LogoutUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `update_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + + 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); @@ -36,13 +101,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -60,13 +125,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -84,13 +149,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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)); @@ -107,13 +172,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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)); @@ -130,13 +195,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -155,13 +220,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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); @@ -178,13 +243,13 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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)); @@ -202,7 +267,7 @@ use super::{Error, configuration}; } else { let status = resp.status(); let content = resp.text().await?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(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 f956d069827..56fdbec97cc 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 @@ -30,19 +30,84 @@ impl PetApiClient { } +/// struct for typed errors of method `add_pet` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddPetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `delete_pet` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeletePetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `find_pets_by_status` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByStatusErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `find_pets_by_tags` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByTagsErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_pet_by_id` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPetByIdErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `update_pet` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `update_pet_with_form` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetWithFormErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `upload_file` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadFileErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + 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; @@ -64,13 +129,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -94,13 +159,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -122,13 +187,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -150,13 +215,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -182,13 +247,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -210,13 +275,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -245,13 +310,13 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -280,7 +345,7 @@ impl PetApi for PetApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(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 04bbf3d4771..c26a8e8f334 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 @@ -30,15 +30,48 @@ impl StoreApiClient { } +/// struct for typed errors of method `delete_order` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_inventory` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInventoryErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_order_by_id` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByIdErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `place_order` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlaceOrderErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + 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; @@ -56,13 +89,13 @@ impl StoreApi for StoreApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -88,13 +121,13 @@ impl StoreApi for StoreApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -112,13 +145,13 @@ impl StoreApi for StoreApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -137,7 +170,7 @@ impl StoreApi for StoreApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(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 2e9d76c80e3..66a4323317d 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 @@ -30,19 +30,84 @@ impl UserApiClient { } +/// struct for typed errors of method `create_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `create_users_with_array_input` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithArrayInputErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `create_users_with_list_input` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithListInputErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `delete_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `get_user_by_name` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByNameErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `login_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum LoginUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `logout_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum LogoutUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} +/// struct for typed errors of method `update_user` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateUserErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + 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; @@ -61,13 +126,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -86,13 +151,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -111,13 +176,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -135,13 +200,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -159,13 +224,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -185,13 +250,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - fn logout_user(&self, ) -> Result<(), Error> { + fn logout_user(&self, ) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; @@ -209,13 +274,13 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } } - 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; @@ -234,7 +299,7 @@ impl UserApi for UserApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) } 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 24f19aa5a9c..d9a2e50db26 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 @@ -30,12 +30,21 @@ impl DefaultApiClient { } +/// struct for typed errors of method `dummy_get` +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum DummyGetErrors { + // TODO Generate an enum case for each error described in schema. + UnknownList(Vec), + UnknownValue(serde_json::Value), +} + 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; @@ -53,7 +62,7 @@ impl DefaultApi for DefaultApiClient { } else { let status = resp.status(); let content = resp.text()?; - let entity: Option = serde_json::from_str(&content).ok(); + let entity: Option = serde_json::from_str(&content).ok(); let error = crate::apis::ResponseErrorContent { status, content, entity }; Err(Error::ResponseError(error)) }