#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
use async_trait::async_trait;
use futures::Stream;
use std::error::Error;
use std::task::{Poll, Context};
use swagger::{ApiError, ContextWrapper};
use serde::{Serialize, Deserialize};
type ServiceError = Box<dyn Error + Send + Sync + 'static>;
pub const BASE_PATH: &'static str = "/v2";
pub const API_VERSION: &'static str = "1.0.0";
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum AddPetResponse {
SuccessfulOperation
(models::Pet)
,
InvalidInput
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum DeletePetResponse {
InvalidPetValue
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum FindPetsByStatusResponse {
SuccessfulOperation
(Vec<models::Pet>)
,
InvalidStatusValue
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum FindPetsByTagsResponse {
SuccessfulOperation
(Vec<models::Pet>)
,
InvalidTagValue
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum GetPetByIdResponse {
SuccessfulOperation
(models::Pet)
,
InvalidIDSupplied
,
PetNotFound
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum UpdatePetResponse {
SuccessfulOperation
(models::Pet)
,
InvalidIDSupplied
,
PetNotFound
,
ValidationException
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum UpdatePetWithFormResponse {
InvalidInput
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum UploadFileResponse {
SuccessfulOperation
(models::ApiResponse)
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum DeleteOrderResponse {
InvalidIDSupplied
,
OrderNotFound
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum GetInventoryResponse {
SuccessfulOperation
(std::collections::HashMap<String, i32>)
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum GetOrderByIdResponse {
SuccessfulOperation
(models::Order)
,
InvalidIDSupplied
,
OrderNotFound
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum PlaceOrderResponse {
SuccessfulOperation
(models::Order)
,
InvalidOrder
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum CreateUserResponse {
SuccessfulOperation
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum CreateUsersWithArrayInputResponse {
SuccessfulOperation
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum CreateUsersWithListInputResponse {
SuccessfulOperation
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum DeleteUserResponse {
InvalidUsernameSupplied
,
UserNotFound
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum GetUserByNameResponse {
SuccessfulOperation
(models::User)
,
InvalidUsernameSupplied
,
UserNotFound
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum LoginUserResponse {
SuccessfulOperation
{
body: String,
set_cookie:
Option<
String
>
,
x_rate_limit:
Option<
i32
>
,
x_expires_after:
Option<
chrono::DateTime::<chrono::Utc>
>
}
,
InvalidUsername
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum LogoutUserResponse {
SuccessfulOperation
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use]
pub enum UpdateUserResponse {
InvalidUserSupplied
,
UserNotFound
}
#[async_trait]
pub trait Api<C: Send + Sync> {
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> {
Poll::Ready(Ok(()))
}
async fn add_pet(
&self,
pet: models::Pet,
context: &C) -> Result<AddPetResponse, ApiError>;
async fn delete_pet(
&self,
pet_id: i64,
api_key: Option<String>,
context: &C) -> Result<DeletePetResponse, ApiError>;
async fn find_pets_by_status(
&self,
status: &Vec<String>,
context: &C) -> Result<FindPetsByStatusResponse, ApiError>;
async fn find_pets_by_tags(
&self,
tags: &Vec<String>,
context: &C) -> Result<FindPetsByTagsResponse, ApiError>;
async fn get_pet_by_id(
&self,
pet_id: i64,
context: &C) -> Result<GetPetByIdResponse, ApiError>;
async fn update_pet(
&self,
pet: models::Pet,
context: &C) -> Result<UpdatePetResponse, ApiError>;
async fn update_pet_with_form(
&self,
pet_id: i64,
name: Option<String>,
status: Option<String>,
context: &C) -> Result<UpdatePetWithFormResponse, ApiError>;
async fn upload_file(
&self,
pet_id: i64,
additional_metadata: Option<String>,
file: Option<swagger::ByteArray>,
context: &C) -> Result<UploadFileResponse, ApiError>;
async fn delete_order(
&self,
order_id: String,
context: &C) -> Result<DeleteOrderResponse, ApiError>;
async fn get_inventory(
&self,
context: &C) -> Result<GetInventoryResponse, ApiError>;
async fn get_order_by_id(
&self,
order_id: i64,
context: &C) -> Result<GetOrderByIdResponse, ApiError>;
async fn place_order(
&self,
order: models::Order,
context: &C) -> Result<PlaceOrderResponse, ApiError>;
async fn create_user(
&self,
user: models::User,
context: &C) -> Result<CreateUserResponse, ApiError>;
async fn create_users_with_array_input(
&self,
user: &Vec<models::User>,
context: &C) -> Result<CreateUsersWithArrayInputResponse, ApiError>;
async fn create_users_with_list_input(
&self,
user: &Vec<models::User>,
context: &C) -> Result<CreateUsersWithListInputResponse, ApiError>;
async fn delete_user(
&self,
username: String,
context: &C) -> Result<DeleteUserResponse, ApiError>;
async fn get_user_by_name(
&self,
username: String,
context: &C) -> Result<GetUserByNameResponse, ApiError>;
async fn login_user(
&self,
username: String,
password: String,
context: &C) -> Result<LoginUserResponse, ApiError>;
async fn logout_user(
&self,
context: &C) -> Result<LogoutUserResponse, ApiError>;
async fn update_user(
&self,
username: String,
user: models::User,
context: &C) -> Result<UpdateUserResponse, ApiError>;
}
#[async_trait]
pub trait ApiNoContext<C: Send + Sync> {
fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>;
fn context(&self) -> &C;
async fn add_pet(
&self,
pet: models::Pet,
) -> Result<AddPetResponse, ApiError>;
async fn delete_pet(
&self,
pet_id: i64,
api_key: Option<String>,
) -> Result<DeletePetResponse, ApiError>;
async fn find_pets_by_status(
&self,
status: &Vec<String>,
) -> Result<FindPetsByStatusResponse, ApiError>;
async fn find_pets_by_tags(
&self,
tags: &Vec<String>,
) -> Result<FindPetsByTagsResponse, ApiError>;
async fn get_pet_by_id(
&self,
pet_id: i64,
) -> Result<GetPetByIdResponse, ApiError>;
async fn update_pet(
&self,
pet: models::Pet,
) -> Result<UpdatePetResponse, ApiError>;
async fn update_pet_with_form(
&self,
pet_id: i64,
name: Option<String>,
status: Option<String>,
) -> Result<UpdatePetWithFormResponse, ApiError>;
async fn upload_file(
&self,
pet_id: i64,
additional_metadata: Option<String>,
file: Option<swagger::ByteArray>,
) -> Result<UploadFileResponse, ApiError>;
async fn delete_order(
&self,
order_id: String,
) -> Result<DeleteOrderResponse, ApiError>;
async fn get_inventory(
&self,
) -> Result<GetInventoryResponse, ApiError>;
async fn get_order_by_id(
&self,
order_id: i64,
) -> Result<GetOrderByIdResponse, ApiError>;
async fn place_order(
&self,
order: models::Order,
) -> Result<PlaceOrderResponse, ApiError>;
async fn create_user(
&self,
user: models::User,
) -> Result<CreateUserResponse, ApiError>;
async fn create_users_with_array_input(
&self,
user: &Vec<models::User>,
) -> Result<CreateUsersWithArrayInputResponse, ApiError>;
async fn create_users_with_list_input(
&self,
user: &Vec<models::User>,
) -> Result<CreateUsersWithListInputResponse, ApiError>;
async fn delete_user(
&self,
username: String,
) -> Result<DeleteUserResponse, ApiError>;
async fn get_user_by_name(
&self,
username: String,
) -> Result<GetUserByNameResponse, ApiError>;
async fn login_user(
&self,
username: String,
password: String,
) -> Result<LoginUserResponse, ApiError>;
async fn logout_user(
&self,
) -> Result<LogoutUserResponse, ApiError>;
async fn update_user(
&self,
username: String,
user: models::User,
) -> Result<UpdateUserResponse, ApiError>;
}
pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized
{
fn with_context(self: Self, context: C) -> ContextWrapper<Self, C>;
}
impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ContextWrapperExt<C> for T {
fn with_context(self: T, context: C) -> ContextWrapper<T, C> {
ContextWrapper::<T, C>::new(self, context)
}
}
#[async_trait]
impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for ContextWrapper<T, C> {
fn poll_ready(&self, cx: &mut Context) -> Poll<Result<(), ServiceError>> {
self.api().poll_ready(cx)
}
fn context(&self) -> &C {
ContextWrapper::context(self)
}
async fn add_pet(
&self,
pet: models::Pet,
) -> Result<AddPetResponse, ApiError>
{
let context = self.context().clone();
self.api().add_pet(pet, &context).await
}
async fn delete_pet(
&self,
pet_id: i64,
api_key: Option<String>,
) -> Result<DeletePetResponse, ApiError>
{
let context = self.context().clone();
self.api().delete_pet(pet_id, api_key, &context).await
}
async fn find_pets_by_status(
&self,
status: &Vec<String>,
) -> Result<FindPetsByStatusResponse, ApiError>
{
let context = self.context().clone();
self.api().find_pets_by_status(status, &context).await
}
async fn find_pets_by_tags(
&self,
tags: &Vec<String>,
) -> Result<FindPetsByTagsResponse, ApiError>
{
let context = self.context().clone();
self.api().find_pets_by_tags(tags, &context).await
}
async fn get_pet_by_id(
&self,
pet_id: i64,
) -> Result<GetPetByIdResponse, ApiError>
{
let context = self.context().clone();
self.api().get_pet_by_id(pet_id, &context).await
}
async fn update_pet(
&self,
pet: models::Pet,
) -> Result<UpdatePetResponse, ApiError>
{
let context = self.context().clone();
self.api().update_pet(pet, &context).await
}
async fn update_pet_with_form(
&self,
pet_id: i64,
name: Option<String>,
status: Option<String>,
) -> Result<UpdatePetWithFormResponse, ApiError>
{
let context = self.context().clone();
self.api().update_pet_with_form(pet_id, name, status, &context).await
}
async fn upload_file(
&self,
pet_id: i64,
additional_metadata: Option<String>,
file: Option<swagger::ByteArray>,
) -> Result<UploadFileResponse, ApiError>
{
let context = self.context().clone();
self.api().upload_file(pet_id, additional_metadata, file, &context).await
}
async fn delete_order(
&self,
order_id: String,
) -> Result<DeleteOrderResponse, ApiError>
{
let context = self.context().clone();
self.api().delete_order(order_id, &context).await
}
async fn get_inventory(
&self,
) -> Result<GetInventoryResponse, ApiError>
{
let context = self.context().clone();
self.api().get_inventory(&context).await
}
async fn get_order_by_id(
&self,
order_id: i64,
) -> Result<GetOrderByIdResponse, ApiError>
{
let context = self.context().clone();
self.api().get_order_by_id(order_id, &context).await
}
async fn place_order(
&self,
order: models::Order,
) -> Result<PlaceOrderResponse, ApiError>
{
let context = self.context().clone();
self.api().place_order(order, &context).await
}
async fn create_user(
&self,
user: models::User,
) -> Result<CreateUserResponse, ApiError>
{
let context = self.context().clone();
self.api().create_user(user, &context).await
}
async fn create_users_with_array_input(
&self,
user: &Vec<models::User>,
) -> Result<CreateUsersWithArrayInputResponse, ApiError>
{
let context = self.context().clone();
self.api().create_users_with_array_input(user, &context).await
}
async fn create_users_with_list_input(
&self,
user: &Vec<models::User>,
) -> Result<CreateUsersWithListInputResponse, ApiError>
{
let context = self.context().clone();
self.api().create_users_with_list_input(user, &context).await
}
async fn delete_user(
&self,
username: String,
) -> Result<DeleteUserResponse, ApiError>
{
let context = self.context().clone();
self.api().delete_user(username, &context).await
}
async fn get_user_by_name(
&self,
username: String,
) -> Result<GetUserByNameResponse, ApiError>
{
let context = self.context().clone();
self.api().get_user_by_name(username, &context).await
}
async fn login_user(
&self,
username: String,
password: String,
) -> Result<LoginUserResponse, ApiError>
{
let context = self.context().clone();
self.api().login_user(username, password, &context).await
}
async fn logout_user(
&self,
) -> Result<LogoutUserResponse, ApiError>
{
let context = self.context().clone();
self.api().logout_user(&context).await
}
async fn update_user(
&self,
username: String,
user: models::User,
) -> Result<UpdateUserResponse, ApiError>
{
let context = self.context().clone();
self.api().update_user(username, user, &context).await
}
}
#[cfg(feature = "client")]
pub mod client;
#[cfg(feature = "client")]
pub use client::Client;
#[cfg(feature = "server")]
pub mod server;
#[cfg(feature = "server")]
pub use self::server::Service;
#[cfg(feature = "server")]
pub mod context;
pub mod models;
#[cfg(any(feature = "client", feature = "server"))]
pub(crate) mod header;