Each API method has is own enum of functionnal errors.

This commit is contained in:
Benoît Courtine 2020-05-29 14:14:34 +02:00
parent ed3e8fbc9b
commit 3ad86b3ddf
9 changed files with 468 additions and 111 deletions

View File

@ -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<serde_json::Value>),
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<serde_json::Value>>;
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<serde_json::Value>>;
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<serde_json::Value>> {
{{#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<serde_json::Value>> {
{{#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::Value> = 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))
}

View File

@ -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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub trait DefaultApi {
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error<serde_json::Value>>;
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error<FileresponsetestErrors>>;
}
impl DefaultApi for DefaultApiClient {
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error<serde_json::Value>> {
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error<FileresponsetestErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<FileresponsetestErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -18,7 +18,72 @@ use reqwest;
use super::{Error, configuration};
pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<serde_json::Value>> {
/// 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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<AddPetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<AddPetErrors> = 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<serde_json::Value>> {
pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DeletePetErrors> = 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<String>) -> Result<Vec<crate::models::Pet>, Error<serde_json::Value>> {
pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<FindPetsByStatusErrors> = 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<String>) -> Result<Vec<crate::models::Pet>, Error<serde_json::Value>> {
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<FindPetsByTagsErrors> = 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<crate::models::Pet, Error<serde_json::Value>> {
pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetPetByIdErrors> = 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<serde_json::Value>> {
pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<UpdatePetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UpdatePetErrors> = 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<serde_json::Value>> {
pub async fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UpdatePetWithFormErrors> = 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<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<serde_json::Value>> {
pub async fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<UploadFileErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UploadFileErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -18,7 +18,40 @@ use reqwest;
use super::{Error, configuration};
pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<serde_json::Value>> {
/// 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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<DeleteOrderErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DeleteOrderErrors> = 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<String, i32>, Error<serde_json::Value>> {
pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetInventoryErrors> = 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<crate::models::Order, Error<serde_json::Value>> {
pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetOrderByIdErrors> = 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<crate::models::Order, Error<serde_json::Value>> {
pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<PlaceOrderErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -18,7 +18,72 @@ use reqwest;
use super::{Error, configuration};
pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error<serde_json::Value>> {
/// 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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error<CreateUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<CreateUserErrors> = 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<crate::models::User>) -> Result<(), Error<serde_json::Value>> {
pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<CreateUsersWithArrayInputErrors> = 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<crate::models::User>) -> Result<(), Error<serde_json::Value>> {
pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<CreateUsersWithListInputErrors> = 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<serde_json::Value>> {
pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error<DeleteUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DeleteUserErrors> = 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<crate::models::User, Error<serde_json::Value>> {
pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result<crate::models::User, Error<GetUserByNameErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetUserByNameErrors> = 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<String, Error<serde_json::Value>> {
pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result<String, Error<LoginUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<LoginUserErrors> = 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<serde_json::Value>> {
pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error<LogoutUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<LogoutUserErrors> = 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<serde_json::Value>> {
pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UpdateUserErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub trait PetApi {
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error<serde_json::Value>>;
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<serde_json::Value>>;
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<serde_json::Value>>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<serde_json::Value>>;
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error<serde_json::Value>>;
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error<serde_json::Value>>;
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<serde_json::Value>>;
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<serde_json::Value>>;
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error<AddPetErrors>>;
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetErrors>>;
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusErrors>>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsErrors>>;
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdErrors>>;
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error<UpdatePetErrors>>;
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormErrors>>;
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<UploadFileErrors>>;
}
impl PetApi for PetApiClient {
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error<serde_json::Value>> {
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error<AddPetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<AddPetErrors> = 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<serde_json::Value>> {
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DeletePetErrors> = 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<String>) -> Result<Vec<crate::models::Pet>, Error<serde_json::Value>> {
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<FindPetsByStatusErrors> = 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<String>) -> Result<Vec<crate::models::Pet>, Error<serde_json::Value>> {
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<FindPetsByTagsErrors> = 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<crate::models::Pet, Error<serde_json::Value>> {
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetPetByIdErrors> = 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<serde_json::Value>> {
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error<UpdatePetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UpdatePetErrors> = 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<serde_json::Value>> {
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UpdatePetWithFormErrors> = 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<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<serde_json::Value>> {
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<UploadFileErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UploadFileErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub trait StoreApi {
fn delete_order(&self, order_id: &str) -> Result<(), Error<serde_json::Value>>;
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error<serde_json::Value>>;
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error<serde_json::Value>>;
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error<serde_json::Value>>;
fn delete_order(&self, order_id: &str) -> Result<(), Error<DeleteOrderErrors>>;
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryErrors>>;
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdErrors>>;
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderErrors>>;
}
impl StoreApi for StoreApiClient {
fn delete_order(&self, order_id: &str) -> Result<(), Error<serde_json::Value>> {
fn delete_order(&self, order_id: &str) -> Result<(), Error<DeleteOrderErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DeleteOrderErrors> = 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<String, i32>, Error<serde_json::Value>> {
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetInventoryErrors> = 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<crate::models::Order, Error<serde_json::Value>> {
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetOrderByIdErrors> = 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<crate::models::Order, Error<serde_json::Value>> {
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<PlaceOrderErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub trait UserApi {
fn create_user(&self, body: crate::models::User) -> Result<(), Error<serde_json::Value>>;
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<serde_json::Value>>;
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<serde_json::Value>>;
fn delete_user(&self, username: &str) -> Result<(), Error<serde_json::Value>>;
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error<serde_json::Value>>;
fn login_user(&self, username: &str, password: &str) -> Result<String, Error<serde_json::Value>>;
fn logout_user(&self, ) -> Result<(), Error<serde_json::Value>>;
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error<serde_json::Value>>;
fn create_user(&self, body: crate::models::User) -> Result<(), Error<CreateUserErrors>>;
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputErrors>>;
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputErrors>>;
fn delete_user(&self, username: &str) -> Result<(), Error<DeleteUserErrors>>;
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error<GetUserByNameErrors>>;
fn login_user(&self, username: &str, password: &str) -> Result<String, Error<LoginUserErrors>>;
fn logout_user(&self, ) -> Result<(), Error<LogoutUserErrors>>;
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserErrors>>;
}
impl UserApi for UserApiClient {
fn create_user(&self, body: crate::models::User) -> Result<(), Error<serde_json::Value>> {
fn create_user(&self, body: crate::models::User) -> Result<(), Error<CreateUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<CreateUserErrors> = 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<crate::models::User>) -> Result<(), Error<serde_json::Value>> {
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<CreateUsersWithArrayInputErrors> = 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<crate::models::User>) -> Result<(), Error<serde_json::Value>> {
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<CreateUsersWithListInputErrors> = 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<serde_json::Value>> {
fn delete_user(&self, username: &str) -> Result<(), Error<DeleteUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DeleteUserErrors> = 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<crate::models::User, Error<serde_json::Value>> {
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error<GetUserByNameErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<GetUserByNameErrors> = 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<String, Error<serde_json::Value>> {
fn login_user(&self, username: &str, password: &str) -> Result<String, Error<LoginUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<LoginUserErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}
}
fn logout_user(&self, ) -> Result<(), Error<serde_json::Value>> {
fn logout_user(&self, ) -> Result<(), Error<LogoutUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<LogoutUserErrors> = 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<serde_json::Value>> {
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<UpdateUserErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}

View File

@ -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<serde_json::Value>),
UnknownValue(serde_json::Value),
}
pub trait DefaultApi {
fn dummy_get(&self, ) -> Result<(), Error<serde_json::Value>>;
fn dummy_get(&self, ) -> Result<(), Error<DummyGetErrors>>;
}
impl DefaultApi for DefaultApiClient {
fn dummy_get(&self, ) -> Result<(), Error<serde_json::Value>> {
fn dummy_get(&self, ) -> Result<(), Error<DummyGetErrors>> {
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::Value> = serde_json::from_str(&content).ok();
let entity: Option<DummyGetErrors> = serde_json::from_str(&content).ok();
let error = crate::apis::ResponseErrorContent { status, content, entity };
Err(Error::ResponseError(error))
}