forked from loafle/openapi-generator-original
Handle several 2xx success models.
This commit is contained in:
parent
ff3d510a69
commit
250d0ede69
@ -6,6 +6,7 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
{{^supportAsync}}
|
{{^supportAsync}}
|
||||||
@ -46,14 +47,31 @@ pub struct {{{operationIdCamelCase}}}Params {
|
|||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/// struct for typed errors of method `{{operationId}}`
|
/// struct for typed successes of method `{{operationId}}`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum {{{operationIdCamelCase}}}Errors {
|
pub enum {{{operationIdCamelCase}}}Success {
|
||||||
{{#responses}}
|
{{#responses}}
|
||||||
|
{{#is2xx}}
|
||||||
|
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||||
|
{{/is2xx}}
|
||||||
{{#is3xx}}
|
{{#is3xx}}
|
||||||
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||||
{{/is3xx}}
|
{{/is3xx}}
|
||||||
|
{{/responses}}
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
/// struct for typed errors of method `{{operationId}}`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum {{{operationIdCamelCase}}}Error {
|
||||||
|
{{#responses}}
|
||||||
{{#is4xx}}
|
{{#is4xx}}
|
||||||
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||||
{{/is4xx}}
|
{{/is4xx}}
|
||||||
@ -76,10 +94,10 @@ pub trait {{{classname}}} {
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#vendorExtensions.x-group-parameters}}
|
{{#vendorExtensions.x-group-parameters}}
|
||||||
fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error<{{{operationIdCamelCase}}}Errors>>;
|
fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>>;
|
||||||
{{/vendorExtensions.x-group-parameters}}
|
{{/vendorExtensions.x-group-parameters}}
|
||||||
{{^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<{{{operationIdCamelCase}}}Errors>>;
|
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<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>>;
|
||||||
{{/vendorExtensions.x-group-parameters}}
|
{{/vendorExtensions.x-group-parameters}}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
@ -90,7 +108,7 @@ impl {{{classname}}} for {{{classname}}}Client {
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#vendorExtensions.x-group-parameters}}
|
{{#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<{{{operationIdCamelCase}}}Errors>> {
|
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>> {
|
||||||
// unbox the parameters
|
// unbox the parameters
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
let {{paramName}} = params.{{paramName}};
|
let {{paramName}} = params.{{paramName}};
|
||||||
@ -98,7 +116,7 @@ impl {{{classname}}} for {{{classname}}}Client {
|
|||||||
|
|
||||||
{{/vendorExtensions.x-group-parameters}}
|
{{/vendorExtensions.x-group-parameters}}
|
||||||
{{^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<{{{operationIdCamelCase}}}Errors>> {
|
{{#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<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>> {
|
||||||
{{/vendorExtensions.x-group-parameters}}
|
{{/vendorExtensions.x-group-parameters}}
|
||||||
{{^supportAsync}}
|
{{^supportAsync}}
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
@ -291,18 +309,17 @@ impl {{{classname}}} for {{{classname}}}Client {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let {{^supportAsync}}mut {{/supportAsync}}resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?;
|
let {{^supportAsync}}mut {{/supportAsync}}resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?;
|
||||||
if resp.status().is_success() {
|
|
||||||
{{^returnType}}
|
let status = resp.status();
|
||||||
Ok(())
|
let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
|
||||||
{{/returnType}}
|
|
||||||
{{#returnType}}
|
if status.is_success() {
|
||||||
Ok(resp.json{{#supportAsync}}::<{{{.}}}>().await{{/supportAsync}}{{^supportAsync}}(){{/supportAsync}}?)
|
let entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&content).ok();
|
||||||
{{/returnType}}
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<{{{operationIdCamelCase}}}Errors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use reqwest;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ResponseErrorContent<T> {
|
pub struct ResponseContent<T> {
|
||||||
pub status: reqwest::StatusCode,
|
pub status: reqwest::StatusCode,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub entity: Option<T>,
|
pub entity: Option<T>,
|
||||||
@ -13,7 +13,7 @@ pub enum Error<T> {
|
|||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
Serde(serde_json::Error),
|
Serde(serde_json::Error),
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
ResponseError(ResponseErrorContent<T>),
|
ResponseError(ResponseContent<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T> From<reqwest::Error> for Error<T> {
|
impl <T> From<reqwest::Error> for Error<T> {
|
||||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct DefaultApiClient {
|
pub struct DefaultApiClient {
|
||||||
@ -30,10 +31,19 @@ impl DefaultApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `fileresponsetest`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum FileresponsetestSuccess {
|
||||||
|
Status200(std::path::PathBuf),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `fileresponsetest`
|
/// struct for typed errors of method `fileresponsetest`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum FileresponsetestErrors {
|
pub enum FileresponsetestError {
|
||||||
DefaultResponse(std::path::PathBuf),
|
DefaultResponse(std::path::PathBuf),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -41,11 +51,11 @@ pub enum FileresponsetestErrors {
|
|||||||
|
|
||||||
|
|
||||||
pub trait DefaultApi {
|
pub trait DefaultApi {
|
||||||
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error<FileresponsetestErrors>>;
|
fn fileresponsetest(&self, ) -> Result<ResponseContent<FileresponsetestSuccess>, Error<FileresponsetestError>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DefaultApi for DefaultApiClient {
|
impl DefaultApi for DefaultApiClient {
|
||||||
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error<FileresponsetestErrors>> {
|
fn fileresponsetest(&self, ) -> Result<ResponseContent<FileresponsetestSuccess>, Error<FileresponsetestError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -58,13 +68,17 @@ impl DefaultApi for DefaultApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<FileresponsetestSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<FileresponsetestError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<FileresponsetestErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use reqwest;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ResponseErrorContent<T> {
|
pub struct ResponseContent<T> {
|
||||||
pub status: reqwest::StatusCode,
|
pub status: reqwest::StatusCode,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub entity: Option<T>,
|
pub entity: Option<T>,
|
||||||
@ -13,7 +13,7 @@ pub enum Error<T> {
|
|||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
Serde(serde_json::Error),
|
Serde(serde_json::Error),
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
ResponseError(ResponseErrorContent<T>),
|
ResponseError(ResponseContent<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T> From<reqwest::Error> for Error<T> {
|
impl <T> From<reqwest::Error> for Error<T> {
|
||||||
|
@ -2,7 +2,7 @@ use reqwest;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ResponseErrorContent<T> {
|
pub struct ResponseContent<T> {
|
||||||
pub status: reqwest::StatusCode,
|
pub status: reqwest::StatusCode,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub entity: Option<T>,
|
pub entity: Option<T>,
|
||||||
@ -13,7 +13,7 @@ pub enum Error<T> {
|
|||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
Serde(serde_json::Error),
|
Serde(serde_json::Error),
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
ResponseError(ResponseErrorContent<T>),
|
ResponseError(ResponseContent<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T> From<reqwest::Error> for Error<T> {
|
impl <T> From<reqwest::Error> for Error<T> {
|
||||||
|
@ -15,13 +15,82 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `add_pet`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum AddPetSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `delete_pet`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DeletePetSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `find_pets_by_status`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum FindPetsByStatusSuccess {
|
||||||
|
Status200(Vec<crate::models::Pet>),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `find_pets_by_tags`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum FindPetsByTagsSuccess {
|
||||||
|
Status200(Vec<crate::models::Pet>),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_pet_by_id`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetPetByIdSuccess {
|
||||||
|
Status200(crate::models::Pet),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `update_pet`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UpdatePetSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `update_pet_with_form`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UpdatePetWithFormSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `upload_file`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UploadFileSuccess {
|
||||||
|
Status200(crate::models::ApiResponse),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `add_pet`
|
/// struct for typed errors of method `add_pet`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum AddPetErrors {
|
pub enum AddPetError {
|
||||||
Status405(),
|
Status405(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -30,7 +99,7 @@ pub enum AddPetErrors {
|
|||||||
/// struct for typed errors of method `delete_pet`
|
/// struct for typed errors of method `delete_pet`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DeletePetErrors {
|
pub enum DeletePetError {
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -39,7 +108,7 @@ pub enum DeletePetErrors {
|
|||||||
/// struct for typed errors of method `find_pets_by_status`
|
/// struct for typed errors of method `find_pets_by_status`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum FindPetsByStatusErrors {
|
pub enum FindPetsByStatusError {
|
||||||
DefaultResponse(Vec<crate::models::Pet>),
|
DefaultResponse(Vec<crate::models::Pet>),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -49,7 +118,7 @@ pub enum FindPetsByStatusErrors {
|
|||||||
/// struct for typed errors of method `find_pets_by_tags`
|
/// struct for typed errors of method `find_pets_by_tags`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum FindPetsByTagsErrors {
|
pub enum FindPetsByTagsError {
|
||||||
DefaultResponse(Vec<crate::models::Pet>),
|
DefaultResponse(Vec<crate::models::Pet>),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -59,7 +128,7 @@ pub enum FindPetsByTagsErrors {
|
|||||||
/// struct for typed errors of method `get_pet_by_id`
|
/// struct for typed errors of method `get_pet_by_id`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetPetByIdErrors {
|
pub enum GetPetByIdError {
|
||||||
DefaultResponse(crate::models::Pet),
|
DefaultResponse(crate::models::Pet),
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
@ -70,7 +139,7 @@ pub enum GetPetByIdErrors {
|
|||||||
/// struct for typed errors of method `update_pet`
|
/// struct for typed errors of method `update_pet`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UpdatePetErrors {
|
pub enum UpdatePetError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
Status405(),
|
Status405(),
|
||||||
@ -81,7 +150,7 @@ pub enum UpdatePetErrors {
|
|||||||
/// struct for typed errors of method `update_pet_with_form`
|
/// struct for typed errors of method `update_pet_with_form`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UpdatePetWithFormErrors {
|
pub enum UpdatePetWithFormError {
|
||||||
Status405(),
|
Status405(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -90,14 +159,14 @@ pub enum UpdatePetWithFormErrors {
|
|||||||
/// struct for typed errors of method `upload_file`
|
/// struct for typed errors of method `upload_file`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UploadFileErrors {
|
pub enum UploadFileError {
|
||||||
DefaultResponse(crate::models::ApiResponse),
|
DefaultResponse(crate::models::ApiResponse),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<AddPetErrors>> {
|
pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<ResponseContent<AddPetSuccess>, Error<AddPetError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet", configuration.base_path);
|
let uri_str = format!("{}/pet", configuration.base_path);
|
||||||
@ -113,18 +182,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<AddPetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<AddPetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetErrors>> {
|
pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<ResponseContent<DeletePetSuccess>, Error<DeletePetError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||||
@ -142,18 +215,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DeletePetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DeletePetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DeletePetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusErrors>> {
|
pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec<String>) -> Result<ResponseContent<FindPetsByStatusSuccess>, Error<FindPetsByStatusError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/findByStatus", configuration.base_path);
|
let uri_str = format!("{}/pet/findByStatus", configuration.base_path);
|
||||||
@ -169,18 +246,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<Vec<crate::models::Pet>>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<FindPetsByStatusSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<FindPetsByStatusErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsErrors>> {
|
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/findByTags", configuration.base_path);
|
let uri_str = format!("{}/pet/findByTags", configuration.base_path);
|
||||||
@ -196,18 +277,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<Vec<crate::models::Pet>>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<FindPetsByTagsSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<FindPetsByTagsErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdErrors>> {
|
pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result<ResponseContent<GetPetByIdSuccess>, Error<GetPetByIdError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||||
@ -227,18 +312,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<crate::models::Pet>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetPetByIdSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetPetByIdErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<UpdatePetErrors>> {
|
pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<ResponseContent<UpdatePetSuccess>, Error<UpdatePetError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet", configuration.base_path);
|
let uri_str = format!("{}/pet", configuration.base_path);
|
||||||
@ -254,18 +343,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UpdatePetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UpdatePetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
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<UpdatePetWithFormErrors>> {
|
pub async fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<ResponseContent<UpdatePetWithFormSuccess>, Error<UpdatePetWithFormError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||||
@ -288,18 +381,22 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UpdatePetWithFormSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UpdatePetWithFormError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UpdatePetWithFormErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
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<UploadFileErrors>> {
|
pub async fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<ResponseContent<UploadFileSuccess>, Error<UploadFileError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
|
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
|
||||||
@ -320,13 +417,17 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<crate::models::ApiResponse>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UploadFileSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UploadFileErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,49 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `delete_order`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DeleteOrderSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_inventory`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetInventorySuccess {
|
||||||
|
Status200(::std::collections::HashMap<String, i32>),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_order_by_id`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetOrderByIdSuccess {
|
||||||
|
Status200(crate::models::Order),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `place_order`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum PlaceOrderSuccess {
|
||||||
|
Status200(crate::models::Order),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `delete_order`
|
/// struct for typed errors of method `delete_order`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DeleteOrderErrors {
|
pub enum DeleteOrderError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -31,7 +67,7 @@ pub enum DeleteOrderErrors {
|
|||||||
/// struct for typed errors of method `get_inventory`
|
/// struct for typed errors of method `get_inventory`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetInventoryErrors {
|
pub enum GetInventoryError {
|
||||||
DefaultResponse(::std::collections::HashMap<String, i32>),
|
DefaultResponse(::std::collections::HashMap<String, i32>),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -40,7 +76,7 @@ pub enum GetInventoryErrors {
|
|||||||
/// struct for typed errors of method `get_order_by_id`
|
/// struct for typed errors of method `get_order_by_id`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetOrderByIdErrors {
|
pub enum GetOrderByIdError {
|
||||||
DefaultResponse(crate::models::Order),
|
DefaultResponse(crate::models::Order),
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
@ -51,7 +87,7 @@ pub enum GetOrderByIdErrors {
|
|||||||
/// struct for typed errors of method `place_order`
|
/// struct for typed errors of method `place_order`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum PlaceOrderErrors {
|
pub enum PlaceOrderError {
|
||||||
DefaultResponse(crate::models::Order),
|
DefaultResponse(crate::models::Order),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -59,7 +95,7 @@ pub enum PlaceOrderErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<DeleteOrderErrors>> {
|
pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<ResponseContent<DeleteOrderSuccess>, Error<DeleteOrderError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
|
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
|
||||||
@ -71,18 +107,22 @@ pub enum PlaceOrderErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DeleteOrderSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DeleteOrderErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryErrors>> {
|
pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<ResponseContent<GetInventorySuccess>, Error<GetInventoryError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/inventory", configuration.base_path);
|
let uri_str = format!("{}/store/inventory", configuration.base_path);
|
||||||
@ -102,18 +142,22 @@ pub enum PlaceOrderErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<::std::collections::HashMap<String, i32>>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetInventorySuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetInventoryErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdErrors>> {
|
pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<ResponseContent<GetOrderByIdSuccess>, Error<GetOrderByIdError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
|
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
|
||||||
@ -125,18 +169,22 @@ pub enum PlaceOrderErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<crate::models::Order>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetOrderByIdSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetOrderByIdErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderErrors>> {
|
pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result<ResponseContent<PlaceOrderSuccess>, Error<PlaceOrderError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order", configuration.base_path);
|
let uri_str = format!("{}/store/order", configuration.base_path);
|
||||||
@ -149,13 +197,17 @@ pub enum PlaceOrderErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<crate::models::Order>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<PlaceOrderSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<PlaceOrderErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,80 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `create_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum CreateUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `create_users_with_array_input`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum CreateUsersWithArrayInputSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `create_users_with_list_input`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum CreateUsersWithListInputSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `delete_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DeleteUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_user_by_name`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetUserByNameSuccess {
|
||||||
|
Status200(crate::models::User),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `login_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum LoginUserSuccess {
|
||||||
|
Status200(String),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `logout_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum LogoutUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `update_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UpdateUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `create_user`
|
/// struct for typed errors of method `create_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateUserErrors {
|
pub enum CreateUserError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -30,7 +97,7 @@ pub enum CreateUserErrors {
|
|||||||
/// struct for typed errors of method `create_users_with_array_input`
|
/// struct for typed errors of method `create_users_with_array_input`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateUsersWithArrayInputErrors {
|
pub enum CreateUsersWithArrayInputError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -39,7 +106,7 @@ pub enum CreateUsersWithArrayInputErrors {
|
|||||||
/// struct for typed errors of method `create_users_with_list_input`
|
/// struct for typed errors of method `create_users_with_list_input`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateUsersWithListInputErrors {
|
pub enum CreateUsersWithListInputError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -48,7 +115,7 @@ pub enum CreateUsersWithListInputErrors {
|
|||||||
/// struct for typed errors of method `delete_user`
|
/// struct for typed errors of method `delete_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DeleteUserErrors {
|
pub enum DeleteUserError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -58,7 +125,7 @@ pub enum DeleteUserErrors {
|
|||||||
/// struct for typed errors of method `get_user_by_name`
|
/// struct for typed errors of method `get_user_by_name`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetUserByNameErrors {
|
pub enum GetUserByNameError {
|
||||||
DefaultResponse(crate::models::User),
|
DefaultResponse(crate::models::User),
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
@ -69,7 +136,7 @@ pub enum GetUserByNameErrors {
|
|||||||
/// struct for typed errors of method `login_user`
|
/// struct for typed errors of method `login_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum LoginUserErrors {
|
pub enum LoginUserError {
|
||||||
DefaultResponse(String),
|
DefaultResponse(String),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -79,7 +146,7 @@ pub enum LoginUserErrors {
|
|||||||
/// struct for typed errors of method `logout_user`
|
/// struct for typed errors of method `logout_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum LogoutUserErrors {
|
pub enum LogoutUserError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -88,7 +155,7 @@ pub enum LogoutUserErrors {
|
|||||||
/// struct for typed errors of method `update_user`
|
/// struct for typed errors of method `update_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UpdateUserErrors {
|
pub enum UpdateUserError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -96,7 +163,7 @@ pub enum UpdateUserErrors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error<CreateUserErrors>> {
|
pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user", configuration.base_path);
|
let uri_str = format!("{}/user", configuration.base_path);
|
||||||
@ -109,18 +176,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<CreateUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<CreateUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputErrors>> {
|
pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithArrayInputSuccess>, Error<CreateUsersWithArrayInputError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
|
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
|
||||||
@ -133,18 +204,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<CreateUsersWithArrayInputSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<CreateUsersWithArrayInputErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputErrors>> {
|
pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithListInputSuccess>, Error<CreateUsersWithListInputError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/createWithList", configuration.base_path);
|
let uri_str = format!("{}/user/createWithList", configuration.base_path);
|
||||||
@ -157,18 +232,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<CreateUsersWithListInputSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<CreateUsersWithListInputErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error<DeleteUserErrors>> {
|
pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<ResponseContent<DeleteUserSuccess>, Error<DeleteUserError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||||
@ -180,18 +259,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DeleteUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DeleteUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result<crate::models::User, Error<GetUserByNameErrors>> {
|
pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result<ResponseContent<GetUserByNameSuccess>, Error<GetUserByNameError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||||
@ -203,18 +286,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<crate::models::User>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetUserByNameSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetUserByNameErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result<String, Error<LoginUserErrors>> {
|
pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result<ResponseContent<LoginUserSuccess>, Error<LoginUserError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/login", configuration.base_path);
|
let uri_str = format!("{}/user/login", configuration.base_path);
|
||||||
@ -228,18 +315,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json::<String>().await?)
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<LoginUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<LoginUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error<LogoutUserErrors>> {
|
pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<ResponseContent<LogoutUserSuccess>, Error<LogoutUserError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/logout", configuration.base_path);
|
let uri_str = format!("{}/user/logout", configuration.base_path);
|
||||||
@ -251,18 +342,22 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<LogoutUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<LogoutUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<LogoutUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserErrors>> {
|
pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<ResponseContent<UpdateUserSuccess>, Error<UpdateUserError>> {
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||||
@ -275,13 +370,17 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let resp = client.execute(req).await?;
|
let resp = client.execute(req).await?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text().await?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UpdateUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UpdateUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text().await?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UpdateUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use reqwest;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ResponseErrorContent<T> {
|
pub struct ResponseContent<T> {
|
||||||
pub status: reqwest::StatusCode,
|
pub status: reqwest::StatusCode,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub entity: Option<T>,
|
pub entity: Option<T>,
|
||||||
@ -13,7 +13,7 @@ pub enum Error<T> {
|
|||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
Serde(serde_json::Error),
|
Serde(serde_json::Error),
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
ResponseError(ResponseErrorContent<T>),
|
ResponseError(ResponseContent<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T> From<reqwest::Error> for Error<T> {
|
impl <T> From<reqwest::Error> for Error<T> {
|
||||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct PetApiClient {
|
pub struct PetApiClient {
|
||||||
@ -30,10 +31,78 @@ impl PetApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `add_pet`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum AddPetSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `delete_pet`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DeletePetSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `find_pets_by_status`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum FindPetsByStatusSuccess {
|
||||||
|
Status200(Vec<crate::models::Pet>),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `find_pets_by_tags`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum FindPetsByTagsSuccess {
|
||||||
|
Status200(Vec<crate::models::Pet>),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_pet_by_id`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetPetByIdSuccess {
|
||||||
|
Status200(crate::models::Pet),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `update_pet`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UpdatePetSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `update_pet_with_form`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UpdatePetWithFormSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `upload_file`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UploadFileSuccess {
|
||||||
|
Status200(crate::models::ApiResponse),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `add_pet`
|
/// struct for typed errors of method `add_pet`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum AddPetErrors {
|
pub enum AddPetError {
|
||||||
Status405(),
|
Status405(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -42,7 +111,7 @@ pub enum AddPetErrors {
|
|||||||
/// struct for typed errors of method `delete_pet`
|
/// struct for typed errors of method `delete_pet`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DeletePetErrors {
|
pub enum DeletePetError {
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -51,7 +120,7 @@ pub enum DeletePetErrors {
|
|||||||
/// struct for typed errors of method `find_pets_by_status`
|
/// struct for typed errors of method `find_pets_by_status`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum FindPetsByStatusErrors {
|
pub enum FindPetsByStatusError {
|
||||||
DefaultResponse(Vec<crate::models::Pet>),
|
DefaultResponse(Vec<crate::models::Pet>),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -61,7 +130,7 @@ pub enum FindPetsByStatusErrors {
|
|||||||
/// struct for typed errors of method `find_pets_by_tags`
|
/// struct for typed errors of method `find_pets_by_tags`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum FindPetsByTagsErrors {
|
pub enum FindPetsByTagsError {
|
||||||
DefaultResponse(Vec<crate::models::Pet>),
|
DefaultResponse(Vec<crate::models::Pet>),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -71,7 +140,7 @@ pub enum FindPetsByTagsErrors {
|
|||||||
/// struct for typed errors of method `get_pet_by_id`
|
/// struct for typed errors of method `get_pet_by_id`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetPetByIdErrors {
|
pub enum GetPetByIdError {
|
||||||
DefaultResponse(crate::models::Pet),
|
DefaultResponse(crate::models::Pet),
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
@ -82,7 +151,7 @@ pub enum GetPetByIdErrors {
|
|||||||
/// struct for typed errors of method `update_pet`
|
/// struct for typed errors of method `update_pet`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UpdatePetErrors {
|
pub enum UpdatePetError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
Status405(),
|
Status405(),
|
||||||
@ -93,7 +162,7 @@ pub enum UpdatePetErrors {
|
|||||||
/// struct for typed errors of method `update_pet_with_form`
|
/// struct for typed errors of method `update_pet_with_form`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UpdatePetWithFormErrors {
|
pub enum UpdatePetWithFormError {
|
||||||
Status405(),
|
Status405(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -102,7 +171,7 @@ pub enum UpdatePetWithFormErrors {
|
|||||||
/// struct for typed errors of method `upload_file`
|
/// struct for typed errors of method `upload_file`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UploadFileErrors {
|
pub enum UploadFileError {
|
||||||
DefaultResponse(crate::models::ApiResponse),
|
DefaultResponse(crate::models::ApiResponse),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -110,18 +179,18 @@ pub enum UploadFileErrors {
|
|||||||
|
|
||||||
|
|
||||||
pub trait PetApi {
|
pub trait PetApi {
|
||||||
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error<AddPetErrors>>;
|
fn add_pet(&self, body: crate::models::Pet) -> Result<ResponseContent<AddPetSuccess>, Error<AddPetError>>;
|
||||||
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetErrors>>;
|
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<ResponseContent<DeletePetSuccess>, Error<DeletePetError>>;
|
||||||
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusErrors>>;
|
fn find_pets_by_status(&self, status: Vec<String>) -> Result<ResponseContent<FindPetsByStatusSuccess>, Error<FindPetsByStatusError>>;
|
||||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsErrors>>;
|
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>>;
|
||||||
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdErrors>>;
|
fn get_pet_by_id(&self, pet_id: i64) -> Result<ResponseContent<GetPetByIdSuccess>, Error<GetPetByIdError>>;
|
||||||
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error<UpdatePetErrors>>;
|
fn update_pet(&self, body: crate::models::Pet) -> Result<ResponseContent<UpdatePetSuccess>, Error<UpdatePetError>>;
|
||||||
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormErrors>>;
|
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<ResponseContent<UpdatePetWithFormSuccess>, Error<UpdatePetWithFormError>>;
|
||||||
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<UploadFileErrors>>;
|
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<ResponseContent<UploadFileSuccess>, Error<UploadFileError>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PetApi for PetApiClient {
|
impl PetApi for PetApiClient {
|
||||||
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error<AddPetErrors>> {
|
fn add_pet(&self, body: crate::models::Pet) -> Result<ResponseContent<AddPetSuccess>, Error<AddPetError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -138,18 +207,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<AddPetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<AddPetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetErrors>> {
|
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<ResponseContent<DeletePetSuccess>, Error<DeletePetError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -168,18 +241,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DeletePetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DeletePetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DeletePetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusErrors>> {
|
fn find_pets_by_status(&self, status: Vec<String>) -> Result<ResponseContent<FindPetsByStatusSuccess>, Error<FindPetsByStatusError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -196,18 +273,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<FindPetsByStatusSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<FindPetsByStatusErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsErrors>> {
|
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -224,18 +305,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<FindPetsByTagsSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<FindPetsByTagsErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdErrors>> {
|
fn get_pet_by_id(&self, pet_id: i64) -> Result<ResponseContent<GetPetByIdSuccess>, Error<GetPetByIdError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -256,18 +341,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetPetByIdSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetPetByIdErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error<UpdatePetErrors>> {
|
fn update_pet(&self, body: crate::models::Pet) -> Result<ResponseContent<UpdatePetSuccess>, Error<UpdatePetError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -284,18 +373,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UpdatePetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UpdatePetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormErrors>> {
|
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<ResponseContent<UpdatePetWithFormSuccess>, Error<UpdatePetWithFormError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -319,18 +412,22 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UpdatePetWithFormSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UpdatePetWithFormError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UpdatePetWithFormErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
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<UploadFileErrors>> {
|
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<ResponseContent<UploadFileSuccess>, Error<UploadFileError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -354,13 +451,17 @@ impl PetApi for PetApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UploadFileSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UploadFileErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct StoreApiClient {
|
pub struct StoreApiClient {
|
||||||
@ -30,10 +31,45 @@ impl StoreApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `delete_order`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DeleteOrderSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_inventory`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetInventorySuccess {
|
||||||
|
Status200(::std::collections::HashMap<String, i32>),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_order_by_id`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetOrderByIdSuccess {
|
||||||
|
Status200(crate::models::Order),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `place_order`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum PlaceOrderSuccess {
|
||||||
|
Status200(crate::models::Order),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `delete_order`
|
/// struct for typed errors of method `delete_order`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DeleteOrderErrors {
|
pub enum DeleteOrderError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -43,7 +79,7 @@ pub enum DeleteOrderErrors {
|
|||||||
/// struct for typed errors of method `get_inventory`
|
/// struct for typed errors of method `get_inventory`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetInventoryErrors {
|
pub enum GetInventoryError {
|
||||||
DefaultResponse(::std::collections::HashMap<String, i32>),
|
DefaultResponse(::std::collections::HashMap<String, i32>),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -52,7 +88,7 @@ pub enum GetInventoryErrors {
|
|||||||
/// struct for typed errors of method `get_order_by_id`
|
/// struct for typed errors of method `get_order_by_id`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetOrderByIdErrors {
|
pub enum GetOrderByIdError {
|
||||||
DefaultResponse(crate::models::Order),
|
DefaultResponse(crate::models::Order),
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
@ -63,7 +99,7 @@ pub enum GetOrderByIdErrors {
|
|||||||
/// struct for typed errors of method `place_order`
|
/// struct for typed errors of method `place_order`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum PlaceOrderErrors {
|
pub enum PlaceOrderError {
|
||||||
DefaultResponse(crate::models::Order),
|
DefaultResponse(crate::models::Order),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -72,14 +108,14 @@ pub enum PlaceOrderErrors {
|
|||||||
|
|
||||||
|
|
||||||
pub trait StoreApi {
|
pub trait StoreApi {
|
||||||
fn delete_order(&self, order_id: &str) -> Result<(), Error<DeleteOrderErrors>>;
|
fn delete_order(&self, order_id: &str) -> Result<ResponseContent<DeleteOrderSuccess>, Error<DeleteOrderError>>;
|
||||||
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryErrors>>;
|
fn get_inventory(&self, ) -> Result<ResponseContent<GetInventorySuccess>, Error<GetInventoryError>>;
|
||||||
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdErrors>>;
|
fn get_order_by_id(&self, order_id: i64) -> Result<ResponseContent<GetOrderByIdSuccess>, Error<GetOrderByIdError>>;
|
||||||
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderErrors>>;
|
fn place_order(&self, body: crate::models::Order) -> Result<ResponseContent<PlaceOrderSuccess>, Error<PlaceOrderError>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StoreApi for StoreApiClient {
|
impl StoreApi for StoreApiClient {
|
||||||
fn delete_order(&self, order_id: &str) -> Result<(), Error<DeleteOrderErrors>> {
|
fn delete_order(&self, order_id: &str) -> Result<ResponseContent<DeleteOrderSuccess>, Error<DeleteOrderError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -92,18 +128,22 @@ impl StoreApi for StoreApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DeleteOrderSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DeleteOrderErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryErrors>> {
|
fn get_inventory(&self, ) -> Result<ResponseContent<GetInventorySuccess>, Error<GetInventoryError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -124,18 +164,22 @@ impl StoreApi for StoreApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetInventorySuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetInventoryErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdErrors>> {
|
fn get_order_by_id(&self, order_id: i64) -> Result<ResponseContent<GetOrderByIdSuccess>, Error<GetOrderByIdError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -148,18 +192,22 @@ impl StoreApi for StoreApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetOrderByIdSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetOrderByIdErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderErrors>> {
|
fn place_order(&self, body: crate::models::Order) -> Result<ResponseContent<PlaceOrderSuccess>, Error<PlaceOrderError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -173,13 +221,17 @@ impl StoreApi for StoreApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<PlaceOrderSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<PlaceOrderErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct UserApiClient {
|
pub struct UserApiClient {
|
||||||
@ -30,10 +31,76 @@ impl UserApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `create_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum CreateUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `create_users_with_array_input`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum CreateUsersWithArrayInputSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `create_users_with_list_input`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum CreateUsersWithListInputSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `delete_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DeleteUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `get_user_by_name`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum GetUserByNameSuccess {
|
||||||
|
Status200(crate::models::User),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `login_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum LoginUserSuccess {
|
||||||
|
Status200(String),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `logout_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum LogoutUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// struct for typed successes of method `update_user`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum UpdateUserSuccess {
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `create_user`
|
/// struct for typed errors of method `create_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateUserErrors {
|
pub enum CreateUserError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -42,7 +109,7 @@ pub enum CreateUserErrors {
|
|||||||
/// struct for typed errors of method `create_users_with_array_input`
|
/// struct for typed errors of method `create_users_with_array_input`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateUsersWithArrayInputErrors {
|
pub enum CreateUsersWithArrayInputError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -51,7 +118,7 @@ pub enum CreateUsersWithArrayInputErrors {
|
|||||||
/// struct for typed errors of method `create_users_with_list_input`
|
/// struct for typed errors of method `create_users_with_list_input`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CreateUsersWithListInputErrors {
|
pub enum CreateUsersWithListInputError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -60,7 +127,7 @@ pub enum CreateUsersWithListInputErrors {
|
|||||||
/// struct for typed errors of method `delete_user`
|
/// struct for typed errors of method `delete_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DeleteUserErrors {
|
pub enum DeleteUserError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -70,7 +137,7 @@ pub enum DeleteUserErrors {
|
|||||||
/// struct for typed errors of method `get_user_by_name`
|
/// struct for typed errors of method `get_user_by_name`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GetUserByNameErrors {
|
pub enum GetUserByNameError {
|
||||||
DefaultResponse(crate::models::User),
|
DefaultResponse(crate::models::User),
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
@ -81,7 +148,7 @@ pub enum GetUserByNameErrors {
|
|||||||
/// struct for typed errors of method `login_user`
|
/// struct for typed errors of method `login_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum LoginUserErrors {
|
pub enum LoginUserError {
|
||||||
DefaultResponse(String),
|
DefaultResponse(String),
|
||||||
Status400(),
|
Status400(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -91,7 +158,7 @@ pub enum LoginUserErrors {
|
|||||||
/// struct for typed errors of method `logout_user`
|
/// struct for typed errors of method `logout_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum LogoutUserErrors {
|
pub enum LogoutUserError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -100,7 +167,7 @@ pub enum LogoutUserErrors {
|
|||||||
/// struct for typed errors of method `update_user`
|
/// struct for typed errors of method `update_user`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum UpdateUserErrors {
|
pub enum UpdateUserError {
|
||||||
Status400(),
|
Status400(),
|
||||||
Status404(),
|
Status404(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
@ -109,18 +176,18 @@ pub enum UpdateUserErrors {
|
|||||||
|
|
||||||
|
|
||||||
pub trait UserApi {
|
pub trait UserApi {
|
||||||
fn create_user(&self, body: crate::models::User) -> Result<(), Error<CreateUserErrors>>;
|
fn create_user(&self, body: crate::models::User) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>>;
|
||||||
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputErrors>>;
|
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithArrayInputSuccess>, Error<CreateUsersWithArrayInputError>>;
|
||||||
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputErrors>>;
|
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithListInputSuccess>, Error<CreateUsersWithListInputError>>;
|
||||||
fn delete_user(&self, username: &str) -> Result<(), Error<DeleteUserErrors>>;
|
fn delete_user(&self, username: &str) -> Result<ResponseContent<DeleteUserSuccess>, Error<DeleteUserError>>;
|
||||||
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error<GetUserByNameErrors>>;
|
fn get_user_by_name(&self, username: &str) -> Result<ResponseContent<GetUserByNameSuccess>, Error<GetUserByNameError>>;
|
||||||
fn login_user(&self, username: &str, password: &str) -> Result<String, Error<LoginUserErrors>>;
|
fn login_user(&self, username: &str, password: &str) -> Result<ResponseContent<LoginUserSuccess>, Error<LoginUserError>>;
|
||||||
fn logout_user(&self, ) -> Result<(), Error<LogoutUserErrors>>;
|
fn logout_user(&self, ) -> Result<ResponseContent<LogoutUserSuccess>, Error<LogoutUserError>>;
|
||||||
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserErrors>>;
|
fn update_user(&self, username: &str, body: crate::models::User) -> Result<ResponseContent<UpdateUserSuccess>, Error<UpdateUserError>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserApi for UserApiClient {
|
impl UserApi for UserApiClient {
|
||||||
fn create_user(&self, body: crate::models::User) -> Result<(), Error<CreateUserErrors>> {
|
fn create_user(&self, body: crate::models::User) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -134,18 +201,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<CreateUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<CreateUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputErrors>> {
|
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithArrayInputSuccess>, Error<CreateUsersWithArrayInputError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -159,18 +230,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<CreateUsersWithArrayInputSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<CreateUsersWithArrayInputErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputErrors>> {
|
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithListInputSuccess>, Error<CreateUsersWithListInputError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -184,18 +259,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<CreateUsersWithListInputSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<CreateUsersWithListInputErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_user(&self, username: &str) -> Result<(), Error<DeleteUserErrors>> {
|
fn delete_user(&self, username: &str) -> Result<ResponseContent<DeleteUserSuccess>, Error<DeleteUserError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -208,18 +287,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DeleteUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DeleteUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error<GetUserByNameErrors>> {
|
fn get_user_by_name(&self, username: &str) -> Result<ResponseContent<GetUserByNameSuccess>, Error<GetUserByNameError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -232,18 +315,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<GetUserByNameSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<GetUserByNameErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn login_user(&self, username: &str, password: &str) -> Result<String, Error<LoginUserErrors>> {
|
fn login_user(&self, username: &str, password: &str) -> Result<ResponseContent<LoginUserSuccess>, Error<LoginUserError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -258,18 +345,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(resp.json()?)
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<LoginUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<LoginUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn logout_user(&self, ) -> Result<(), Error<LogoutUserErrors>> {
|
fn logout_user(&self, ) -> Result<ResponseContent<LogoutUserSuccess>, Error<LogoutUserError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -282,18 +373,22 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<LogoutUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<LogoutUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<LogoutUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserErrors>> {
|
fn update_user(&self, username: &str, body: crate::models::User) -> Result<ResponseContent<UpdateUserSuccess>, Error<UpdateUserError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -307,13 +402,17 @@ impl UserApi for UserApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<UpdateUserSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<UpdateUserError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<UpdateUserErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
|
use crate::apis::ResponseContent;
|
||||||
use super::{Error, configuration};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct DefaultApiClient {
|
pub struct DefaultApiClient {
|
||||||
@ -30,10 +31,19 @@ impl DefaultApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// struct for typed successes of method `dummy_get`
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum DummyGetSuccess {
|
||||||
|
Status200(),
|
||||||
|
UnknownList(Vec<serde_json::Value>),
|
||||||
|
UnknownValue(serde_json::Value),
|
||||||
|
}
|
||||||
|
|
||||||
/// struct for typed errors of method `dummy_get`
|
/// struct for typed errors of method `dummy_get`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum DummyGetErrors {
|
pub enum DummyGetError {
|
||||||
DefaultResponse(),
|
DefaultResponse(),
|
||||||
UnknownList(Vec<serde_json::Value>),
|
UnknownList(Vec<serde_json::Value>),
|
||||||
UnknownValue(serde_json::Value),
|
UnknownValue(serde_json::Value),
|
||||||
@ -41,11 +51,11 @@ pub enum DummyGetErrors {
|
|||||||
|
|
||||||
|
|
||||||
pub trait DefaultApi {
|
pub trait DefaultApi {
|
||||||
fn dummy_get(&self, ) -> Result<(), Error<DummyGetErrors>>;
|
fn dummy_get(&self, ) -> Result<ResponseContent<DummyGetSuccess>, Error<DummyGetError>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DefaultApi for DefaultApiClient {
|
impl DefaultApi for DefaultApiClient {
|
||||||
fn dummy_get(&self, ) -> Result<(), Error<DummyGetErrors>> {
|
fn dummy_get(&self, ) -> Result<ResponseContent<DummyGetSuccess>, Error<DummyGetError>> {
|
||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
@ -58,13 +68,17 @@ impl DefaultApi for DefaultApiClient {
|
|||||||
|
|
||||||
let req = req_builder.build()?;
|
let req = req_builder.build()?;
|
||||||
let mut resp = client.execute(req)?;
|
let mut resp = client.execute(req)?;
|
||||||
if resp.status().is_success() {
|
|
||||||
Ok(())
|
let status = resp.status();
|
||||||
|
let content = resp.text()?;
|
||||||
|
|
||||||
|
if status.is_success() {
|
||||||
|
let entity: Option<DummyGetSuccess> = serde_json::from_str(&content).ok();
|
||||||
|
let result = ResponseContent { status, content, entity };
|
||||||
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let entity: Option<DummyGetError> = serde_json::from_str(&content).ok();
|
||||||
let content = resp.text()?;
|
let error = ResponseContent { status, content, entity };
|
||||||
let entity: Option<DummyGetErrors> = serde_json::from_str(&content).ok();
|
|
||||||
let error = crate::apis::ResponseErrorContent { status, content, entity };
|
|
||||||
Err(Error::ResponseError(error))
|
Err(Error::ResponseError(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use reqwest;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ResponseErrorContent<T> {
|
pub struct ResponseContent<T> {
|
||||||
pub status: reqwest::StatusCode,
|
pub status: reqwest::StatusCode,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub entity: Option<T>,
|
pub entity: Option<T>,
|
||||||
@ -13,7 +13,7 @@ pub enum Error<T> {
|
|||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
Serde(serde_json::Error),
|
Serde(serde_json::Error),
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
ResponseError(ResponseErrorContent<T>),
|
ResponseError(ResponseContent<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T> From<reqwest::Error> for Error<T> {
|
impl <T> From<reqwest::Error> for Error<T> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user