example export interface OrderTTT { format id ? : number ; format petId ? : number ; format quantity ? : number ; format shipDate ? : string ; /** Order Status */ status ? : "placed" | "approved" | "delivered" | null ; complete ? : boolean ; } example export interface CategoryTTT { format id ? : number ; name ? : string ; } example export interface UserTTT { format id ? : number ; username ? : string ; firstName ? : string ; lastName ? : string ; email ? : string ; password ? : string ; phone ? : string ; format userStatus ? : number ; } example export interface TagTTT { format id ? : number ; name ? : string ; } export enum PetNamesTTT { FluffyHero = "Fluffy Hero" , PiggyPo = "Piggy Po" , SwaggerTypescriptApi = "Swagger Typescript Api" , UPPER_CASE = "UPPER_CASE" } export type PetIdsTTT = 10 | 20 | 30 | 40 ; export type PetIdsWithWrongEnumTTT = 10 | 20 | 30 | 40 ; example export interface PetTTT { format id ? : number ; /** A category for a pet */ category ? : CategoryTTT ; example name : string ; photoUrls : string [ ] ; tags ? : TagTTT [ ] ; /** pet status in the store */ status ? : "available" | "pending" | "sold" ; } example export interface ApiResponseTTT { format code ? : number ; type ? : string ; message ? : string ; } /**
 * some description
 */ export interface AmountTTT { format min max value : number ; /**
     * some description
     *
     */ currency : CurrencyTTT ; } pattern export type CurrencyTTT = string ; export interface SingleFormUrlEncodedRequestPayloadTTT { format param1 : string ; param2 : string ; } export interface UpdatePetWithFormPayloadTTT { /** Updated name of the pet */ name ? : string ; /** Updated status of the pet */ status ? : string ; } export interface UploadFilePayloadTTT { /** Additional data to pass to server */ additionalMetadata ? : string ; /** file to upload */ file ? : File ; } export type QueryParamsType = Record < string | number , any > ; export type ResponseFormat = keyof Omit < Body , "body" | "bodyUsed" > ; export interface FullRequestParams extends Omit < RequestInit , "body" > { /** set parameter to `true` for call `securityWorker` for this request */ secure ? : boolean ; /** request path */ path : string ; /** content type of request body */ type ? : ContentType ; /** query params */ query ? : QueryParamsType ; /** format of response (i.e. response.json() -> format: "json") */ format ? : ResponseFormat ; /** request body */ body ? : unknown ; /** base url */ baseUrl ? : string ; /** request cancellation token */ cancelToken ? : CancelToken ; } export type RequestParams = Omit < FullRequestParams , "body" | "method" | "query" | "path" > ; export interface ApiConfig < SecurityDataType = unknown > { baseUrl ? : string ; baseApiParams ? : Omit < RequestParams , "baseUrl" | "cancelToken" | "signal" > ; securityWorker ? : ( securityData : SecurityDataType | null ) => Promise < RequestParams | void > | RequestParams | void ; customFetch ? : typeof fetch ; } export interface HttpResponse < D extends unknown , E extends unknown = unknown > extends Response { data : D ; error : E ; } type CancelToken = Symbol | string | number ; export enum ContentType { Json = "application/json" , FormData = "multipart/form-data" , UrlEncoded = "application/x-www-form-urlencoded" } export class HttpClient < SecurityDataType = unknown > { public baseUrl : string = "http://petstore.swagger.io/v2" ; private securityData : SecurityDataType | null = null ; private securityWorker ? : ApiConfig < SecurityDataType > [ "securityWorker" ] ; private abortControllers = new Map < CancelToken , AbortController > ( ) ; private customFetch = ( ... fetchParams ) => fetch ( ... fetchParams ) ; private baseApiParams : RequestParams = { credentials : "same-origin" , headers : { } , redirect : "follow" , referrerPolicy : "no-referrer" , } ; constructor ( apiConfig = { } ) { Object . assign ( this , apiConfig ) ; } public setSecurityData = ( data ) => { this . securityData = data ; } ; private encodeQueryParam ( key , value ) { const encodedKey = encodeURIComponent ( key ) ; return `${ encodedKey }=${ encodeURIComponent ( typeof value === "number" ? value : `${ value }` ) }` ; } private addQueryParam ( query , key ) { return this . encodeQueryParam ( key , query [ key ] ) ; } private addArrayQueryParam ( query , key ) { const value = query [ key ] ; return value . map ( ( v ) => this . encodeQueryParam ( key , v ) ) . join ( "&" ) ; } protected toQueryString ( rawQuery ? ) { const query = rawQuery || { } ; const keys = Object . keys ( query ) . filter ( ( key ) => "undefined" !== typeof query [ key ] ) ; return keys . map ( ( key ) => ( Array . isArray ( query [ key ] ) ? this . addArrayQueryParam ( query , key ) : this . addQueryParam ( query , key ) ) ) . join ( "&" ) ; } protected addQueryParams ( rawQuery ? ) { const queryString = this . toQueryString ( rawQuery ) ; return queryString ? `?${ queryString }` : "" ; } private contentFormatters : Record < ContentType , ( input : any ) => any > = { [ ContentType . Json ] : ( input ) => input !== null && ( typeof input === "object" || typeof input === "string" ) ? JSON . stringify ( input ) : input , [ ContentType . FormData ] : ( input ) => Object . keys ( input || { } ) . reduce ( ( formData , key ) => { const property = input [ key ] ; formData . append ( key , property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON . stringify ( property ) : `${ property }` ) ; return formData ; } , new FormData ( ) ) , [ ContentType . UrlEncoded ] : ( input ) => this . toQueryString ( input ) , } ; private mergeRequestParams ( params1 , params2 ? ) { return { ... this . baseApiParams , ... params1 , ... ( params2 || { } ) , headers : { ... ( this . baseApiParams . headers || { } ) , ... ( params1 . headers || { } ) , ... ( ( params2 && params2 . headers ) || { } ) , } , } ; } private createAbortSignal = ( cancelToken ) : AbortSignal | undefined => { if ( this . abortControllers . has ( cancelToken ) ) { const abortController = this . abortControllers . get ( cancelToken ) ; if ( abortController ) { return abortController . signal ; } return void 0 ; } const abortController = new AbortController ( ) ; this . abortControllers . set ( cancelToken , abortController ) ; return abortController . signal ; } ; public abortRequest = ( cancelToken ) => { const abortController = this . abortControllers . get ( cancelToken ) ; if ( abortController ) { abortController . abort ( ) ; this . abortControllers . delete ( cancelToken ) ; } } ; public request = async < T = any , E = any > ( { body , secure , path , type , query , format , baseUrl , cancelToken , ... params } ) : Promise < HttpResponse < T , E > > => { const secureParams = ( ( typeof secure === "boolean" ? secure : this . baseApiParams . secure ) && this . securityWorker && ( await this . securityWorker ( this . securityData ) ) ) || { } ; const requestParams = this . mergeRequestParams ( params , secureParams ) ; const queryString = query && this . toQueryString ( query ) ; const payloadFormatter = this . contentFormatters [ type || ContentType . Json ] ; const responseFormat = format || requestParams . format ; return this . customFetch ( `${ baseUrl || this . baseUrl || "" }${ path }${ queryString ? `?${ queryString }` : "" }` , { ... requestParams , headers : { ... ( type && type !== ContentType . FormData ? { "Content-Type" : type } : { } ) , ... ( requestParams . headers || { } ) , } , signal : cancelToken ? this . createAbortSignal ( cancelToken ) : void 0 , body : typeof body === "undefined" || body === null ? null : payloadFormatter ( body ) , } ) . then ( async ( response ) => { const r = response as HttpResponse < T , E > ; r . data = ( null as unknown ) as T ; r . error = ( null as unknown ) as E ; const data = ! responseFormat ? r : await response [ responseFormat ] ( ) . then ( ( data ) => { if ( r . ok ) { r . data = data ; } else { r . error = data ; } return r ; } ) . catch ( ( e ) => { r . error = e ; return r ; } ) ; if ( cancelToken ) { this . abortControllers . delete ( cancelToken ) ; } if ( ! response . ok ) throw data ; return data ; } ) ; } ; } title version license termsOfService baseUrl externalDocs contact export class Api < SecurityDataType extends unknown > extends HttpClient < SecurityDataType > { pet = { tags name summary request secure addPet : ( body , params = { } ) => this . request < any , void > ( { path : `/pet` , method : "POST" , body : body , secure : true , type : ContentType . Json , ... params , } ) , tags name summary request secure updatePet : ( body , params = { } ) => this . request < any , void > ( { path : `/pet` , method : "PUT" , body : body , secure : true , type : ContentType . Json , ... params , } ) , description tags name summary request secure findPetsByStatus : ( query , params = { } ) => this . request < PetTTT [ ] , void > ( { path : `/pet/findByStatus` , method : "GET" , query : query , secure : true , format : "json" , ... params , } ) , tags name summary request singleFormUrlEncodedRequest : ( data , params = { } ) => this . request < void , void > ( { path : `/pet/single-form-url-encoded` , method : "POST" , body : data , type : ContentType . UrlEncoded , ... params , } ) , tags name summary request formUrlEncodedRequest : ( data , params = { } ) => this . request < void , void > ( { path : `/pet/form-url-encoded` , method : "POST" , body : data , type : ContentType . UrlEncoded , ... params , } ) , tags name summary request originalName duplicate formUrlEncodedRequest2 : ( data , params = { } ) => this . request < void , void > ( { path : `/pet/end-form-url-encoded` , method : "POST" , body : data , type : ContentType . UrlEncoded , ... params , } ) , description tags name summary request deprecated secure findPetsByTags : ( query , params = { } ) => this . request < PetTTT [ ] , void > ( { path : `/pet/findByTags` , method : "GET" , query : query , secure : true , format : "json" , ... params , } ) , description tags name summary request secure getPetById : ( petId , params = { } ) => this . request < PetTTT , void > ( { path : `/pet/${ petId }` , method : "GET" , secure : true , format : "json" , ... params , } ) , tags name summary request secure updatePetWithForm : ( petId , data , params = { } ) => this . request < any , void > ( { path : `/pet/${ petId }` , method : "POST" , body : data , secure : true , type : ContentType . FormData , ... params , } ) , tags name summary request secure deletePet : ( petId , params = { } ) => this . request < any , void > ( { path : `/pet/${ petId }` , method : "DELETE" , secure : true , ... params , } ) , tags name summary request secure uploadFile : ( petId , data , params = { } ) => this . request < ApiResponseTTT , any > ( { path : `/pet/${ petId }/uploadImage` , method : "POST" , body : data , secure : true , type : ContentType . FormData , format : "json" , ... params , } ) , } ; store = { description tags name summary request secure getInventory : ( params = { } ) => this . request < Record < string , number > , any > ( { path : `/store/inventory` , method : "GET" , secure : true , format : "json" , ... params , } ) , tags name summary request placeOrder : ( body , params = { } ) => this . request < OrderTTT , void > ( { path : `/store/order` , method : "POST" , body : body , type : ContentType . Json , format : "json" , ... params , } ) , description tags name summary request getOrderById : ( orderId , params = { } ) => this . request < OrderTTT , void > ( { path : `/store/order/${ orderId }` , method : "GET" , format : "json" , ... params , } ) , description tags name summary request deleteOrder : ( orderId , params = { } ) => this . request < any , void > ( { path : `/store/order/${ orderId }` , method : "DELETE" , ... params , } ) , } ; user = { description tags name summary request createUser : ( body , params = { } ) => this . request < any , void > ( { path : `/user` , method : "POST" , body : body , type : ContentType . Json , ... params , } ) , tags name summary request createUsersWithArrayInput : ( body , params = { } ) => this . request < any , void > ( { path : `/user/createWithArray` , method : "POST" , body : body , type : ContentType . Json , ... params , } ) , tags name summary request createUsersWithListInput : ( body , params = { } ) => this . request < any , void > ( { path : `/user/createWithList` , method : "POST" , body : body , type : ContentType . Json , ... params , } ) , tags name summary request loginUser : ( query , params = { } ) => this . request < CurrencyTTT , void > ( { path : `/user/login` , method : "GET" , query : query , format : "json" , ... params , } ) , tags name summary request logoutUser : ( params = { } ) => this . request < any , void > ( { path : `/user/logout` , method : "GET" , ... params , } ) , tags name summary request getUserByName : ( username , params = { } ) => this . request < UserTTT , void > ( { path : `/user/${ username }` , method : "GET" , format : "json" , ... params , } ) , description tags name summary request updateUser : ( username , body , params = { } ) => this . request < any , void > ( { path : `/user/${ username }` , method : "PUT" , body : body , type : ContentType . Json , ... params , } ) , description tags name summary request deleteUser : ( username , params = { } ) => this . request < any , void > ( { path : `/user/${ username }` , method : "DELETE" , ... params , } ) , } ; }