forked from loafle/openapi-generator-original
fix response
This commit is contained in:
commit
0a3592de80
@ -3613,12 +3613,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
op.uniqueItems = true;
|
||||
imports.add(typeMapping.get(r.containerType));
|
||||
}
|
||||
//r.isDefault = response == methodResponse;
|
||||
|
||||
op.responses.add(r);
|
||||
if (Boolean.TRUE.equals(r.isBinary) && Boolean.TRUE.equals(r.isDefault)) {
|
||||
if (Boolean.TRUE.equals(r.isBinary) && Boolean.TRUE.equals(r.is2xx) && Boolean.FALSE.equals(op.isResponseBinary)) {
|
||||
op.isResponseBinary = Boolean.TRUE;
|
||||
}
|
||||
if (Boolean.TRUE.equals(r.isFile) && Boolean.TRUE.equals(r.isDefault)) {
|
||||
if (Boolean.TRUE.equals(r.isFile) && Boolean.TRUE.equals(r.is2xx) && Boolean.FALSE.equals(op.isResponseFile)) {
|
||||
op.isResponseFile = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
@ -3845,14 +3845,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
r.code = responseCode;
|
||||
if ("default".equals(responseCode) || "defaultResponse".equals(responseCode)) {
|
||||
r.code = "0";
|
||||
}
|
||||
r.isDefault = true;
|
||||
} else {
|
||||
r.code = responseCode;
|
||||
switch (r.code.charAt(0)) {
|
||||
case '0':
|
||||
r.isDefault = true;
|
||||
break;
|
||||
case '1':
|
||||
r.is1xx = true;
|
||||
break;
|
||||
@ -3871,7 +3869,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
default:
|
||||
throw new RuntimeException("Invalid response code " + responseCode);
|
||||
}
|
||||
|
||||
}
|
||||
Schema responseSchema;
|
||||
if (this.openAPI != null && this.openAPI.getComponents() != null) {
|
||||
responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(response),
|
||||
|
@ -1,11 +1,12 @@
|
||||
{{>partial_header}}
|
||||
#[allow(unused_imports)]
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
{{^supportAsync}}use std::borrow::Borrow;{{/supportAsync}}
|
||||
use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
{{^supportAsync}}
|
||||
@ -44,15 +45,59 @@ pub struct {{{operationIdCamelCase}}}Params {
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
/// struct for typed successes of method `{{operationId}}`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum {{{operationIdCamelCase}}}Success {
|
||||
{{#responses}}
|
||||
{{#is2xx}}
|
||||
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||
{{/is2xx}}
|
||||
{{#is3xx}}
|
||||
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||
{{/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}}
|
||||
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||
{{/is4xx}}
|
||||
{{#is5xx}}
|
||||
Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||
{{/is5xx}}
|
||||
{{#isDefault}}
|
||||
DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}),
|
||||
{{/isDefault}}
|
||||
{{/responses}}
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
{{^supportAsync}}
|
||||
pub trait {{{classname}}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
|
||||
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}}
|
||||
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
|
||||
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>>;
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@ -63,7 +108,7 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
|
||||
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>> {
|
||||
// unbox the parameters
|
||||
{{#allParams}}
|
||||
let {{paramName}} = params.{{paramName}};
|
||||
@ -71,7 +116,7 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{^vendorExtensions.x-group-parameters}}
|
||||
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
|
||||
{{#supportAsync}}pub async {{/supportAsync}}fn {{{operationId}}}({{^supportAsync}}&self{{/supportAsync}}{{#supportAsync}}configuration: &configuration::Configuration{{/supportAsync}}, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<ResponseContent<{{{operationIdCamelCase}}}Success>, Error<{{{operationIdCamelCase}}}Error>> {
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{^supportAsync}}
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
@ -263,18 +308,20 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
{{/hasBodyParam}}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
{{^returnType}}
|
||||
client.execute(req){{#supportAsync}}.await{{/supportAsync}}?.error_for_status()?;
|
||||
Ok(())
|
||||
{{/returnType}}
|
||||
{{#returnType}}
|
||||
{{#supportAsync}}
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<{{{.}}}>().await?)
|
||||
{{/supportAsync}}
|
||||
{{^supportAsync}}
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
{{/supportAsync}}
|
||||
{{/returnType}}
|
||||
let {{^supportAsync}}mut {{/supportAsync}}resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
|
||||
let status = resp.status();
|
||||
let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
|
||||
if status.is_success() {
|
||||
let entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&content).ok();
|
||||
let result = ResponseContent { status, content, entity };
|
||||
Ok(result)
|
||||
} else {
|
||||
let entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
|
@ -1,26 +1,34 @@
|
||||
use reqwest;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
pub status: reqwest::StatusCode,
|
||||
pub content: String,
|
||||
pub entity: Option<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
pub enum Error<T> {
|
||||
Reqwest(reqwest::Error),
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
impl <T> From<reqwest::Error> for Error<T> {
|
||||
fn from(e: reqwest::Error) -> Self {
|
||||
Error::Reqwest(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
impl <T> From<serde_json::Error> for Error<T> {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
impl <T> From<std::io::Error> for Error<T> {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
@ -32,26 +40,7 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
mod {{{classFilename}}};
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{^supportAsync}}
|
||||
{{#-first}}
|
||||
pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client };
|
||||
{{/-first}}
|
||||
{{/supportAsync}}
|
||||
{{#supportAsync}}
|
||||
pub use self::{{{classFilename}}}::{ {{{operationId}}} };
|
||||
{{/supportAsync}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#allParams}}
|
||||
{{#-first}}
|
||||
pub use self::{{{classFilename}}}::{{{operationIdCamelCase}}}Params as {{{classname}}}{{{operationIdCamelCase}}}Params;
|
||||
{{/-first}}
|
||||
{{/allParams}}
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
pub mod {{{classFilename}}};
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
|
@ -8,7 +8,7 @@ pub struct APIClient {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box<dyn crate::apis::{{{classname}}}>,
|
||||
{{{classFilename}}}: Box<dyn crate::apis::{{{classFilename}}}::{{{classname}}}>,
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@ -26,7 +26,7 @@ impl APIClient {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())),
|
||||
{{{classFilename}}}: Box::new(crate::apis::{{{classFilename}}}::{{{classname}}}Client::new(rc.clone())),
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@ -40,7 +40,7 @@ impl APIClient {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{
|
||||
pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classFilename}}}::{{{classname}}}{
|
||||
self.{{{classFilename}}}.as_ref()
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
default_api: Box<dyn crate::apis::DefaultApi>,
|
||||
default_api: Box<dyn crate::apis::default_api::DefaultApi>,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
@ -11,11 +11,11 @@ impl APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())),
|
||||
default_api: Box::new(crate::apis::default_api::DefaultApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{
|
||||
pub fn default_api(&self) -> &dyn crate::apis::default_api::DefaultApi{
|
||||
self.default_api.as_ref()
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
pub struct DefaultApiClient {
|
||||
@ -30,12 +31,31 @@ 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FileresponsetestError {
|
||||
DefaultResponse(std::path::PathBuf),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub trait DefaultApi {
|
||||
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error>;
|
||||
fn fileresponsetest(&self, ) -> Result<ResponseContent<FileresponsetestSuccess>, Error<FileresponsetestError>>;
|
||||
}
|
||||
|
||||
impl DefaultApi for DefaultApiClient {
|
||||
fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error> {
|
||||
fn fileresponsetest(&self, ) -> Result<ResponseContent<FileresponsetestSuccess>, Error<FileresponsetestError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -47,7 +67,20 @@ impl DefaultApi for DefaultApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<FileresponsetestError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,26 +1,34 @@
|
||||
use reqwest;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
pub status: reqwest::StatusCode,
|
||||
pub content: String,
|
||||
pub entity: Option<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
pub enum Error<T> {
|
||||
Reqwest(reqwest::Error),
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
impl <T> From<reqwest::Error> for Error<T> {
|
||||
fn from(e: reqwest::Error) -> Self {
|
||||
Error::Reqwest(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
impl <T> From<serde_json::Error> for Error<T> {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
impl <T> From<std::io::Error> for Error<T> {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
@ -30,8 +38,7 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||
}
|
||||
|
||||
mod default_api;
|
||||
pub use self::default_api::{ DefaultApi, DefaultApiClient };
|
||||
pub mod default_api;
|
||||
|
||||
pub mod client;
|
||||
pub mod configuration;
|
||||
|
@ -1,26 +1,34 @@
|
||||
use reqwest;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
pub status: reqwest::StatusCode,
|
||||
pub content: String,
|
||||
pub entity: Option<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
pub enum Error<T> {
|
||||
Reqwest(reqwest::Error),
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
impl <T> From<reqwest::Error> for Error<T> {
|
||||
fn from(e: reqwest::Error) -> Self {
|
||||
Error::Reqwest(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
impl <T> From<serde_json::Error> for Error<T> {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
impl <T> From<std::io::Error> for Error<T> {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
@ -30,6 +38,7 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
mod pet_api;
|
||||
pub use self::pet_api::{ add_pet };
|
||||
pub use self::pet_api::AddPetParams as PetApiAddPetParams;
|
||||
@ -71,5 +80,10 @@ pub use self::user_api::LoginUserParams as UserApiLoginUserParams;
|
||||
pub use self::user_api::{ logout_user };
|
||||
pub use self::user_api::{ update_user };
|
||||
pub use self::user_api::UpdateUserParams as UserApiUpdateUserParams;
|
||||
=======
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
pub mod user_api;
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,11 +10,12 @@
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
|
||||
use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
/// struct for passing parameters to the method `add_pet`
|
||||
@ -87,6 +88,157 @@ pub struct UploadFileParams {
|
||||
// unbox the parameters
|
||||
let body = params.body;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/// 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum AddPetError {
|
||||
Status405(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `delete_pet`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeletePetError {
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `find_pets_by_status`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FindPetsByStatusError {
|
||||
DefaultResponse(Vec<crate::models::Pet>),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `find_pets_by_tags`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FindPetsByTagsError {
|
||||
DefaultResponse(Vec<crate::models::Pet>),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_pet_by_id`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetPetByIdError {
|
||||
DefaultResponse(crate::models::Pet),
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `update_pet`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdatePetError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
Status405(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `update_pet_with_form`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdatePetWithFormError {
|
||||
Status405(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `upload_file`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UploadFileError {
|
||||
DefaultResponse(crate::models::ApiResponse),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub async fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<ResponseContent<AddPetSuccess>, Error<AddPetError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet", configuration.base_path);
|
||||
@ -101,15 +253,31 @@ pub struct UploadFileParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn delete_pet(configuration: &configuration::Configuration, params: DeletePetParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let pet_id = params.pet_id;
|
||||
let api_key = params.api_key;
|
||||
|
||||
=======
|
||||
pub async fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<ResponseContent<DeletePetSuccess>, Error<DeletePetError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||
@ -126,14 +294,30 @@ pub struct UploadFileParams {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DeletePetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn find_pets_by_status(configuration: &configuration::Configuration, params: FindPetsByStatusParams) -> Result<Vec<crate::models::Pet>, Error> {
|
||||
// unbox the parameters
|
||||
let status = params.status;
|
||||
|
||||
=======
|
||||
pub async fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec<String>) -> Result<ResponseContent<FindPetsByStatusSuccess>, Error<FindPetsByStatusError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet/findByStatus", configuration.base_path);
|
||||
@ -148,13 +332,30 @@ pub struct UploadFileParams {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<Vec<crate::models::Pet>>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result<Vec<crate::models::Pet>, Error> {
|
||||
// unbox the parameters
|
||||
let tags = params.tags;
|
||||
|
||||
=======
|
||||
pub async fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet/findByTags", configuration.base_path);
|
||||
@ -169,13 +370,30 @@ pub struct UploadFileParams {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<Vec<crate::models::Pet>>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: GetPetByIdParams) -> Result<crate::models::Pet, Error> {
|
||||
// unbox the parameters
|
||||
let pet_id = params.pet_id;
|
||||
|
||||
=======
|
||||
pub async fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result<ResponseContent<GetPetByIdSuccess>, Error<GetPetByIdError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||
@ -194,13 +412,30 @@ pub struct UploadFileParams {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<crate::models::Pet>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn update_pet(configuration: &configuration::Configuration, params: UpdatePetParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let body = params.body;
|
||||
|
||||
=======
|
||||
pub async fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<ResponseContent<UpdatePetSuccess>, Error<UpdatePetError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet", configuration.base_path);
|
||||
@ -215,16 +450,32 @@ pub struct UploadFileParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn update_pet_with_form(configuration: &configuration::Configuration, params: UpdatePetWithFormParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let pet_id = params.pet_id;
|
||||
let name = params.name;
|
||||
let status = params.status;
|
||||
|
||||
=======
|
||||
pub async fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<ResponseContent<UpdatePetWithFormSuccess>, Error<UpdatePetWithFormError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||
@ -246,16 +497,32 @@ pub struct UploadFileParams {
|
||||
req_builder = req_builder.form(&form_params);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UpdatePetWithFormError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn upload_file(configuration: &configuration::Configuration, params: UploadFileParams) -> Result<crate::models::ApiResponse, Error> {
|
||||
// unbox the parameters
|
||||
let pet_id = params.pet_id;
|
||||
let additional_metadata = params.additional_metadata;
|
||||
let file = params.file;
|
||||
|
||||
=======
|
||||
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>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
|
||||
@ -275,6 +542,19 @@ pub struct UploadFileParams {
|
||||
req_builder = req_builder.multipart(form);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<crate::models::ApiResponse>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,12 @@
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
|
||||
use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
/// struct for passing parameters to the method `delete_order`
|
||||
@ -43,6 +44,86 @@ pub struct PlaceOrderParams {
|
||||
// unbox the parameters
|
||||
let order_id = params.order_id;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/// 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeleteOrderError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_inventory`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetInventoryError {
|
||||
DefaultResponse(::std::collections::HashMap<String, i32>),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_order_by_id`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetOrderByIdError {
|
||||
DefaultResponse(crate::models::Order),
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `place_order`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PlaceOrderError {
|
||||
DefaultResponse(crate::models::Order),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub async fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<ResponseContent<DeleteOrderSuccess>, Error<DeleteOrderError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
|
||||
@ -53,13 +134,29 @@ pub struct PlaceOrderParams {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn get_inventory(configuration: &configuration::Configuration) -> Result<::std::collections::HashMap<String, i32>, Error> {
|
||||
// unbox the parameters
|
||||
|
||||
=======
|
||||
pub async fn get_inventory(configuration: &configuration::Configuration, ) -> Result<ResponseContent<GetInventorySuccess>, Error<GetInventoryError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/store/inventory", configuration.base_path);
|
||||
@ -78,13 +175,30 @@ pub struct PlaceOrderParams {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<::std::collections::HashMap<String, i32>>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn get_order_by_id(configuration: &configuration::Configuration, params: GetOrderByIdParams) -> Result<crate::models::Order, Error> {
|
||||
// unbox the parameters
|
||||
let order_id = params.order_id;
|
||||
|
||||
=======
|
||||
pub async fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<ResponseContent<GetOrderByIdSuccess>, Error<GetOrderByIdError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
|
||||
@ -95,13 +209,30 @@ pub struct PlaceOrderParams {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<crate::models::Order>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn place_order(configuration: &configuration::Configuration, params: PlaceOrderParams) -> Result<crate::models::Order, Error> {
|
||||
// unbox the parameters
|
||||
let body = params.body;
|
||||
|
||||
=======
|
||||
pub async fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result<ResponseContent<PlaceOrderSuccess>, Error<PlaceOrderError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/store/order", configuration.base_path);
|
||||
@ -113,6 +244,19 @@ pub struct PlaceOrderParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<crate::models::Order>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,12 @@
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
|
||||
use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
/// struct for passing parameters to the method `create_user`
|
||||
@ -75,6 +76,154 @@ pub struct UpdateUserParams {
|
||||
// unbox the parameters
|
||||
let body = params.body;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/// 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUserError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `create_users_with_array_input`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUsersWithArrayInputError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `create_users_with_list_input`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUsersWithListInputError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `delete_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeleteUserError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_user_by_name`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetUserByNameError {
|
||||
DefaultResponse(crate::models::User),
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `login_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum LoginUserError {
|
||||
DefaultResponse(String),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `logout_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum LogoutUserError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `update_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdateUserError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub async fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user", configuration.base_path);
|
||||
@ -86,14 +235,30 @@ pub struct UpdateUserParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn create_users_with_array_input(configuration: &configuration::Configuration, params: CreateUsersWithArrayInputParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let body = params.body;
|
||||
|
||||
=======
|
||||
pub async fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithArrayInputSuccess>, Error<CreateUsersWithArrayInputError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
|
||||
@ -105,14 +270,30 @@ pub struct UpdateUserParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn create_users_with_list_input(configuration: &configuration::Configuration, params: CreateUsersWithListInputParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let body = params.body;
|
||||
|
||||
=======
|
||||
pub async fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<ResponseContent<CreateUsersWithListInputSuccess>, Error<CreateUsersWithListInputError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/createWithList", configuration.base_path);
|
||||
@ -124,14 +305,30 @@ pub struct UpdateUserParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let username = params.username;
|
||||
|
||||
=======
|
||||
pub async fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<ResponseContent<DeleteUserSuccess>, Error<DeleteUserError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||
@ -142,14 +339,30 @@ pub struct UpdateUserParams {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn get_user_by_name(configuration: &configuration::Configuration, params: GetUserByNameParams) -> Result<crate::models::User, Error> {
|
||||
// unbox the parameters
|
||||
let username = params.username;
|
||||
|
||||
=======
|
||||
pub async fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result<ResponseContent<GetUserByNameSuccess>, Error<GetUserByNameError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||
@ -160,14 +373,31 @@ pub struct UpdateUserParams {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<crate::models::User>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn login_user(configuration: &configuration::Configuration, params: LoginUserParams) -> Result<String, Error> {
|
||||
// unbox the parameters
|
||||
let username = params.username;
|
||||
let password = params.password;
|
||||
|
||||
=======
|
||||
pub async fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result<ResponseContent<LoginUserSuccess>, Error<LoginUserError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/login", configuration.base_path);
|
||||
@ -180,12 +410,29 @@ pub struct UpdateUserParams {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req).await?.error_for_status()?.json::<String>().await?)
|
||||
let resp = client.execute(req).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 {
|
||||
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn logout_user(configuration: &configuration::Configuration) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
|
||||
=======
|
||||
pub async fn logout_user(configuration: &configuration::Configuration, ) -> Result<ResponseContent<LogoutUserSuccess>, Error<LogoutUserError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/logout", configuration.base_path);
|
||||
@ -196,15 +443,31 @@ pub struct UpdateUserParams {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<LogoutUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result<(), Error> {
|
||||
// unbox the parameters
|
||||
let username = params.username;
|
||||
let body = params.body;
|
||||
|
||||
=======
|
||||
pub async fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<ResponseContent<UpdateUserSuccess>, Error<UpdateUserError>> {
|
||||
>>>>>>> 733fd9d601b19862de26b8424106f60cd9716e6c
|
||||
let client = &configuration.client;
|
||||
|
||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||
@ -216,7 +479,19 @@ pub struct UpdateUserParams {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req).await?.error_for_status()?;
|
||||
Ok(())
|
||||
let resp = client.execute(req).await?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UpdateUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ use petstore_reqwest_async::apis::configuration;
|
||||
//use petstore_reqwest::apis::PetApiUpdatePetWithFormParams;
|
||||
use petstore_reqwest_async::models::{Pet};
|
||||
use std::option::Option;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn test_pet() {
|
||||
@ -18,17 +17,10 @@ fn test_pet() {
|
||||
new_pet.id = Option::Some(8787);
|
||||
|
||||
// add pet
|
||||
let _add_result = petstore_reqwest_async::apis::add_pet(&config, new_pet);
|
||||
let _add_result = petstore_reqwest_async::apis::pet_api::add_pet(&config, new_pet);
|
||||
|
||||
// get pet
|
||||
let pet_result = petstore_reqwest_async::apis::get_pet_by_id(&config, 8787);
|
||||
let pet_result = petstore_reqwest_async::apis::pet_api::get_pet_by_id(&config, 8787);
|
||||
|
||||
let _pet_result = match pet_result {
|
||||
Ok(pet) => {
|
||||
assert_eq!(pet.id, Option::Some(8787));
|
||||
assert_eq!(pet.name, "Rust Pet");
|
||||
assert_eq!(pet.photo_urls, vec!["https://11".to_string(), "https://22".to_string()]);
|
||||
},
|
||||
Err(error) => println!("error: {:?}", error),
|
||||
};
|
||||
// TODO Testing async functions requires some additionnal testing crates.
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ use std::rc::Rc;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
pet_api: Box<dyn crate::apis::PetApi>,
|
||||
store_api: Box<dyn crate::apis::StoreApi>,
|
||||
user_api: Box<dyn crate::apis::UserApi>,
|
||||
pet_api: Box<dyn crate::apis::pet_api::PetApi>,
|
||||
store_api: Box<dyn crate::apis::store_api::StoreApi>,
|
||||
user_api: Box<dyn crate::apis::user_api::UserApi>,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
@ -13,21 +13,21 @@ impl APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
||||
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
||||
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
||||
pet_api: Box::new(crate::apis::pet_api::PetApiClient::new(rc.clone())),
|
||||
store_api: Box::new(crate::apis::store_api::StoreApiClient::new(rc.clone())),
|
||||
user_api: Box::new(crate::apis::user_api::UserApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pet_api(&self) -> &dyn crate::apis::PetApi{
|
||||
pub fn pet_api(&self) -> &dyn crate::apis::pet_api::PetApi{
|
||||
self.pet_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn store_api(&self) -> &dyn crate::apis::StoreApi{
|
||||
pub fn store_api(&self) -> &dyn crate::apis::store_api::StoreApi{
|
||||
self.store_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn user_api(&self) -> &dyn crate::apis::UserApi{
|
||||
pub fn user_api(&self) -> &dyn crate::apis::user_api::UserApi{
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
|
||||
|
@ -1,26 +1,34 @@
|
||||
use reqwest;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
pub status: reqwest::StatusCode,
|
||||
pub content: String,
|
||||
pub entity: Option<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
pub enum Error<T> {
|
||||
Reqwest(reqwest::Error),
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
impl <T> From<reqwest::Error> for Error<T> {
|
||||
fn from(e: reqwest::Error) -> Self {
|
||||
Error::Reqwest(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
impl <T> From<serde_json::Error> for Error<T> {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
impl <T> From<std::io::Error> for Error<T> {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
@ -30,12 +38,9 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||
}
|
||||
|
||||
mod pet_api;
|
||||
pub use self::pet_api::{ PetApi, PetApiClient };
|
||||
mod store_api;
|
||||
pub use self::store_api::{ StoreApi, StoreApiClient };
|
||||
mod user_api;
|
||||
pub use self::user_api::{ UserApi, UserApiClient };
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
pub mod user_api;
|
||||
|
||||
pub mod client;
|
||||
pub mod configuration;
|
||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
pub struct PetApiClient {
|
||||
@ -30,19 +31,166 @@ 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum AddPetError {
|
||||
Status405(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `delete_pet`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeletePetError {
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `find_pets_by_status`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FindPetsByStatusError {
|
||||
DefaultResponse(Vec<crate::models::Pet>),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `find_pets_by_tags`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FindPetsByTagsError {
|
||||
DefaultResponse(Vec<crate::models::Pet>),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_pet_by_id`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetPetByIdError {
|
||||
DefaultResponse(crate::models::Pet),
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `update_pet`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdatePetError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
Status405(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `update_pet_with_form`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdatePetWithFormError {
|
||||
Status405(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `upload_file`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UploadFileError {
|
||||
DefaultResponse(crate::models::ApiResponse),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub trait PetApi {
|
||||
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error>;
|
||||
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error>;
|
||||
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error>;
|
||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error>;
|
||||
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error>;
|
||||
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error>;
|
||||
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error>;
|
||||
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error>;
|
||||
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<ResponseContent<DeletePetSuccess>, Error<DeletePetError>>;
|
||||
fn find_pets_by_status(&self, status: Vec<String>) -> Result<ResponseContent<FindPetsByStatusSuccess>, Error<FindPetsByStatusError>>;
|
||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>>;
|
||||
fn get_pet_by_id(&self, pet_id: i64) -> Result<ResponseContent<GetPetByIdSuccess>, Error<GetPetByIdError>>;
|
||||
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<ResponseContent<UpdatePetWithFormSuccess>, Error<UpdatePetWithFormError>>;
|
||||
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 {
|
||||
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error> {
|
||||
fn add_pet(&self, body: crate::models::Pet) -> Result<ResponseContent<AddPetSuccess>, Error<AddPetError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -58,11 +206,23 @@ impl PetApi for PetApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> {
|
||||
fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<ResponseContent<DeletePetSuccess>, Error<DeletePetError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -80,11 +240,23 @@ impl PetApi for PetApiClient {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DeletePetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error> {
|
||||
fn find_pets_by_status(&self, status: Vec<String>) -> Result<ResponseContent<FindPetsByStatusSuccess>, Error<FindPetsByStatusError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -100,10 +272,23 @@ impl PetApi for PetApiClient {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error> {
|
||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<ResponseContent<FindPetsByTagsSuccess>, Error<FindPetsByTagsError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -119,10 +304,23 @@ impl PetApi for PetApiClient {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error> {
|
||||
fn get_pet_by_id(&self, pet_id: i64) -> Result<ResponseContent<GetPetByIdSuccess>, Error<GetPetByIdError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -142,10 +340,23 @@ impl PetApi for PetApiClient {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error> {
|
||||
fn update_pet(&self, body: crate::models::Pet) -> Result<ResponseContent<UpdatePetSuccess>, Error<UpdatePetError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -161,11 +372,23 @@ impl PetApi for PetApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> {
|
||||
fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<ResponseContent<UpdatePetWithFormSuccess>, Error<UpdatePetWithFormError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -188,11 +411,23 @@ impl PetApi for PetApiClient {
|
||||
req_builder = req_builder.form(&form_params);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UpdatePetWithFormError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error> {
|
||||
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 client = &configuration.client;
|
||||
|
||||
@ -215,7 +450,20 @@ impl PetApi for PetApiClient {
|
||||
req_builder = req_builder.multipart(form);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
pub struct StoreApiClient {
|
||||
@ -30,15 +31,91 @@ 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeleteOrderError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_inventory`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetInventoryError {
|
||||
DefaultResponse(::std::collections::HashMap<String, i32>),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_order_by_id`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetOrderByIdError {
|
||||
DefaultResponse(crate::models::Order),
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `place_order`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PlaceOrderError {
|
||||
DefaultResponse(crate::models::Order),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub trait StoreApi {
|
||||
fn delete_order(&self, order_id: &str) -> Result<(), Error>;
|
||||
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error>;
|
||||
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error>;
|
||||
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error>;
|
||||
fn delete_order(&self, order_id: &str) -> Result<ResponseContent<DeleteOrderSuccess>, Error<DeleteOrderError>>;
|
||||
fn get_inventory(&self, ) -> Result<ResponseContent<GetInventorySuccess>, Error<GetInventoryError>>;
|
||||
fn get_order_by_id(&self, order_id: i64) -> Result<ResponseContent<GetOrderByIdSuccess>, Error<GetOrderByIdError>>;
|
||||
fn place_order(&self, body: crate::models::Order) -> Result<ResponseContent<PlaceOrderSuccess>, Error<PlaceOrderError>>;
|
||||
}
|
||||
|
||||
impl StoreApi for StoreApiClient {
|
||||
fn delete_order(&self, order_id: &str) -> Result<(), Error> {
|
||||
fn delete_order(&self, order_id: &str) -> Result<ResponseContent<DeleteOrderSuccess>, Error<DeleteOrderError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -50,11 +127,23 @@ impl StoreApi for StoreApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error> {
|
||||
fn get_inventory(&self, ) -> Result<ResponseContent<GetInventorySuccess>, Error<GetInventoryError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -74,10 +163,23 @@ impl StoreApi for StoreApiClient {
|
||||
};
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error> {
|
||||
fn get_order_by_id(&self, order_id: i64) -> Result<ResponseContent<GetOrderByIdSuccess>, Error<GetOrderByIdError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -89,10 +191,23 @@ impl StoreApi for StoreApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error> {
|
||||
fn place_order(&self, body: crate::models::Order) -> Result<ResponseContent<PlaceOrderSuccess>, Error<PlaceOrderError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -105,7 +220,20 @@ impl StoreApi for StoreApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
pub struct UserApiClient {
|
||||
@ -30,19 +31,163 @@ 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUserError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `create_users_with_array_input`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUsersWithArrayInputError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `create_users_with_list_input`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum CreateUsersWithListInputError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `delete_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DeleteUserError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `get_user_by_name`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum GetUserByNameError {
|
||||
DefaultResponse(crate::models::User),
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `login_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum LoginUserError {
|
||||
DefaultResponse(String),
|
||||
Status400(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `logout_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum LogoutUserError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
/// struct for typed errors of method `update_user`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum UpdateUserError {
|
||||
Status400(),
|
||||
Status404(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub trait UserApi {
|
||||
fn create_user(&self, body: crate::models::User) -> Result<(), Error>;
|
||||
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error>;
|
||||
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error>;
|
||||
fn delete_user(&self, username: &str) -> Result<(), Error>;
|
||||
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error>;
|
||||
fn login_user(&self, username: &str, password: &str) -> Result<String, Error>;
|
||||
fn logout_user(&self, ) -> Result<(), Error>;
|
||||
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error>;
|
||||
fn create_user(&self, body: crate::models::User) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>>;
|
||||
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<ResponseContent<CreateUsersWithListInputSuccess>, Error<CreateUsersWithListInputError>>;
|
||||
fn delete_user(&self, username: &str) -> Result<ResponseContent<DeleteUserSuccess>, Error<DeleteUserError>>;
|
||||
fn get_user_by_name(&self, username: &str) -> Result<ResponseContent<GetUserByNameSuccess>, Error<GetUserByNameError>>;
|
||||
fn login_user(&self, username: &str, password: &str) -> Result<ResponseContent<LoginUserSuccess>, Error<LoginUserError>>;
|
||||
fn logout_user(&self, ) -> Result<ResponseContent<LogoutUserSuccess>, Error<LogoutUserError>>;
|
||||
fn update_user(&self, username: &str, body: crate::models::User) -> Result<ResponseContent<UpdateUserSuccess>, Error<UpdateUserError>>;
|
||||
}
|
||||
|
||||
impl UserApi for UserApiClient {
|
||||
fn create_user(&self, body: crate::models::User) -> Result<(), Error> {
|
||||
fn create_user(&self, body: crate::models::User) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -55,11 +200,23 @@ impl UserApi for UserApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error> {
|
||||
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 client = &configuration.client;
|
||||
|
||||
@ -72,11 +229,23 @@ impl UserApi for UserApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error> {
|
||||
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 client = &configuration.client;
|
||||
|
||||
@ -89,11 +258,23 @@ impl UserApi for UserApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn delete_user(&self, username: &str) -> Result<(), Error> {
|
||||
fn delete_user(&self, username: &str) -> Result<ResponseContent<DeleteUserSuccess>, Error<DeleteUserError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -105,11 +286,23 @@ impl UserApi for UserApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error> {
|
||||
fn get_user_by_name(&self, username: &str) -> Result<ResponseContent<GetUserByNameSuccess>, Error<GetUserByNameError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -121,10 +314,23 @@ impl UserApi for UserApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn login_user(&self, username: &str, password: &str) -> Result<String, Error> {
|
||||
fn login_user(&self, username: &str, password: &str) -> Result<ResponseContent<LoginUserSuccess>, Error<LoginUserError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -138,10 +344,23 @@ impl UserApi for UserApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
Ok(client.execute(req)?.error_for_status()?.json()?)
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn logout_user(&self, ) -> Result<(), Error> {
|
||||
fn logout_user(&self, ) -> Result<ResponseContent<LogoutUserSuccess>, Error<LogoutUserError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -153,11 +372,23 @@ impl UserApi for UserApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<LogoutUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error> {
|
||||
fn update_user(&self, username: &str, body: crate::models::User) -> Result<ResponseContent<UpdateUserSuccess>, Error<UpdateUserError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -170,8 +401,20 @@ impl UserApi for UserApiClient {
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<UpdateUserError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
extern crate petstore_reqwest;
|
||||
use petstore_reqwest::apis::PetApi;
|
||||
use petstore_reqwest::apis::PetApiClient;
|
||||
use petstore_reqwest::apis::pet_api::PetApi;
|
||||
use petstore_reqwest::apis::pet_api::PetApiClient;
|
||||
use petstore_reqwest::apis::configuration;
|
||||
//use petstore_reqwest::apis::PetApiUpdatePetWithFormParams;
|
||||
use petstore_reqwest::models::{Pet};
|
||||
use std::option::Option;
|
||||
use std::rc::Rc;
|
||||
@ -23,12 +22,22 @@ fn test_pet() {
|
||||
// get pet
|
||||
let pet_result = pet_api_client.get_pet_by_id(8787);
|
||||
|
||||
let _pet_result = match pet_result {
|
||||
Ok(pet) => {
|
||||
assert_eq!(pet.id, Option::Some(8787));
|
||||
assert_eq!(pet.name, "Rust Pet");
|
||||
assert_eq!(pet.photo_urls, vec!["https://11".to_string(), "https://22".to_string()]);
|
||||
match pet_result {
|
||||
Ok(resp) => {
|
||||
match resp.entity {
|
||||
Some(petstore_reqwest::apis::pet_api::GetPetByIdSuccess::Status200(pet)) => {
|
||||
assert_eq!(pet.id, Option::Some(8787));
|
||||
assert_eq!(pet.name, "Rust Pet");
|
||||
assert_eq!(pet.photo_urls, vec!["https://11".to_string(), "https://22".to_string()]);
|
||||
},
|
||||
_ => {
|
||||
panic!("Response should contain a pet entity");
|
||||
},
|
||||
};
|
||||
},
|
||||
Err(error) => {
|
||||
println!("error: {:?}", error);
|
||||
panic!("Query should succeed");
|
||||
},
|
||||
Err(error) => println!("error: {:?}", error),
|
||||
};
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
default_api: Box<dyn crate::apis::DefaultApi>,
|
||||
default_api: Box<dyn crate::apis::default_api::DefaultApi>,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
@ -11,11 +11,11 @@ impl APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())),
|
||||
default_api: Box::new(crate::apis::default_api::DefaultApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{
|
||||
pub fn default_api(&self) -> &dyn crate::apis::default_api::DefaultApi{
|
||||
self.default_api.as_ref()
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ use std::option::Option;
|
||||
|
||||
use reqwest;
|
||||
|
||||
use crate::apis::ResponseContent;
|
||||
use super::{Error, configuration};
|
||||
|
||||
pub struct DefaultApiClient {
|
||||
@ -30,12 +31,31 @@ 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`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DummyGetError {
|
||||
DefaultResponse(),
|
||||
UnknownList(Vec<serde_json::Value>),
|
||||
UnknownValue(serde_json::Value),
|
||||
}
|
||||
|
||||
|
||||
pub trait DefaultApi {
|
||||
fn dummy_get(&self, ) -> Result<(), Error>;
|
||||
fn dummy_get(&self, ) -> Result<ResponseContent<DummyGetSuccess>, Error<DummyGetError>>;
|
||||
}
|
||||
|
||||
impl DefaultApi for DefaultApiClient {
|
||||
fn dummy_get(&self, ) -> Result<(), Error> {
|
||||
fn dummy_get(&self, ) -> Result<ResponseContent<DummyGetSuccess>, Error<DummyGetError>> {
|
||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||
let client = &configuration.client;
|
||||
|
||||
@ -47,8 +67,20 @@ impl DefaultApi for DefaultApiClient {
|
||||
}
|
||||
|
||||
let req = req_builder.build()?;
|
||||
client.execute(req)?.error_for_status()?;
|
||||
Ok(())
|
||||
let mut resp = client.execute(req)?;
|
||||
|
||||
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 {
|
||||
let entity: Option<DummyGetError> = serde_json::from_str(&content).ok();
|
||||
let error = ResponseContent { status, content, entity };
|
||||
Err(Error::ResponseError(error))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,26 +1,34 @@
|
||||
use reqwest;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseContent<T> {
|
||||
pub status: reqwest::StatusCode,
|
||||
pub content: String,
|
||||
pub entity: Option<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
pub enum Error<T> {
|
||||
Reqwest(reqwest::Error),
|
||||
Serde(serde_json::Error),
|
||||
Io(std::io::Error),
|
||||
ResponseError(ResponseContent<T>),
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
impl <T> From<reqwest::Error> for Error<T> {
|
||||
fn from(e: reqwest::Error) -> Self {
|
||||
Error::Reqwest(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
impl <T> From<serde_json::Error> for Error<T> {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
impl <T> From<std::io::Error> for Error<T> {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
@ -30,8 +38,7 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||
}
|
||||
|
||||
mod default_api;
|
||||
pub use self::default_api::{ DefaultApi, DefaultApiClient };
|
||||
pub mod default_api;
|
||||
|
||||
pub mod client;
|
||||
pub mod configuration;
|
||||
|
Loading…
x
Reference in New Issue
Block a user