11/* eslint-disable */
22/* tslint:disable */
3+ // @ts -nocheck
34/*
45 * ---------------------------------------------------------------
56 * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
@@ -115,16 +116,22 @@ export interface FullRequestParams extends Omit<RequestInit, "body"> {
115116 cancelToken ?: CancelToken ;
116117}
117118
118- export type RequestParams = Omit < FullRequestParams , "body" | "method" | "query" | "path" > ;
119+ export type RequestParams = Omit <
120+ FullRequestParams ,
121+ "body" | "method" | "query" | "path"
122+ > ;
119123
120124export interface ApiConfig < SecurityDataType = unknown > {
121125 baseUrl ?: string ;
122126 baseApiParams ?: Omit < RequestParams , "baseUrl" | "cancelToken" | "signal" > ;
123- securityWorker ?: ( securityData : SecurityDataType | null ) => Promise < RequestParams | void > | RequestParams | void ;
127+ securityWorker ?: (
128+ securityData : SecurityDataType | null ,
129+ ) => Promise < RequestParams | void > | RequestParams | void ;
124130 customFetch ?: typeof fetch ;
125131}
126132
127- export interface HttpResponse < D extends unknown , E extends unknown = unknown > extends Response {
133+ export interface HttpResponse < D extends unknown , E extends unknown = unknown >
134+ extends Response {
128135 data : D ;
129136 error : E ;
130137}
@@ -133,17 +140,19 @@ type CancelToken = Symbol | string | number;
133140
134141export enum ContentType {
135142 Json = "application/json" ,
143+ JsonApi = "application/vnd.api+json" ,
136144 FormData = "multipart/form-data" ,
137145 UrlEncoded = "application/x-www-form-urlencoded" ,
138146 Text = "text/plain" ,
139147}
140148
141149export class HttpClient < SecurityDataType = unknown > {
142- public baseUrl : string = "https://api.realworld.io /api" ;
150+ public baseUrl : string = "https://api.realworld.show /api" ;
143151 private securityData : SecurityDataType | null = null ;
144152 private securityWorker ?: ApiConfig < SecurityDataType > [ "securityWorker" ] ;
145153 private abortControllers = new Map < CancelToken , AbortController > ( ) ;
146- private customFetch = ( ...fetchParams : Parameters < typeof fetch > ) => fetch ( ...fetchParams ) ;
154+ private customFetch = ( ...fetchParams : Parameters < typeof fetch > ) =>
155+ fetch ( ...fetchParams ) ;
147156
148157 private baseApiParams : RequestParams = {
149158 credentials : "same-origin" ,
@@ -176,9 +185,15 @@ export class HttpClient<SecurityDataType = unknown> {
176185
177186 protected toQueryString ( rawQuery ?: QueryParamsType ) : string {
178187 const query = rawQuery || { } ;
179- const keys = Object . keys ( query ) . filter ( ( key ) => "undefined" !== typeof query [ key ] ) ;
188+ const keys = Object . keys ( query ) . filter (
189+ ( key ) => "undefined" !== typeof query [ key ] ,
190+ ) ;
180191 return keys
181- . map ( ( key ) => ( Array . isArray ( query [ key ] ) ? this . addArrayQueryParam ( query , key ) : this . addQueryParam ( query , key ) ) )
192+ . map ( ( key ) =>
193+ Array . isArray ( query [ key ] )
194+ ? this . addArrayQueryParam ( query , key )
195+ : this . addQueryParam ( query , key ) ,
196+ )
182197 . join ( "&" ) ;
183198 }
184199
@@ -189,10 +204,23 @@ export class HttpClient<SecurityDataType = unknown> {
189204
190205 private contentFormatters : Record < ContentType , ( input : any ) => any > = {
191206 [ ContentType . Json ] : ( input : any ) =>
192- input !== null && ( typeof input === "object" || typeof input === "string" ) ? JSON . stringify ( input ) : input ,
193- [ ContentType . Text ] : ( input : any ) => ( input !== null && typeof input !== "string" ? JSON . stringify ( input ) : input ) ,
194- [ ContentType . FormData ] : ( input : any ) =>
195- Object . keys ( input || { } ) . reduce ( ( formData , key ) => {
207+ input !== null && ( typeof input === "object" || typeof input === "string" )
208+ ? JSON . stringify ( input )
209+ : input ,
210+ [ ContentType . JsonApi ] : ( input : any ) =>
211+ input !== null && ( typeof input === "object" || typeof input === "string" )
212+ ? JSON . stringify ( input )
213+ : input ,
214+ [ ContentType . Text ] : ( input : any ) =>
215+ input !== null && typeof input !== "string"
216+ ? JSON . stringify ( input )
217+ : input ,
218+ [ ContentType . FormData ] : ( input : any ) => {
219+ if ( input instanceof FormData ) {
220+ return input ;
221+ }
222+
223+ return Object . keys ( input || { } ) . reduce ( ( formData , key ) => {
196224 const property = input [ key ] ;
197225 formData . append (
198226 key ,
@@ -203,11 +231,15 @@ export class HttpClient<SecurityDataType = unknown> {
203231 : `${ property } ` ,
204232 ) ;
205233 return formData ;
206- } , new FormData ( ) ) ,
234+ } , new FormData ( ) ) ;
235+ } ,
207236 [ ContentType . UrlEncoded ] : ( input : any ) => this . toQueryString ( input ) ,
208237 } ;
209238
210- protected mergeRequestParams ( params1 : RequestParams , params2 ?: RequestParams ) : RequestParams {
239+ protected mergeRequestParams (
240+ params1 : RequestParams ,
241+ params2 ?: RequestParams ,
242+ ) : RequestParams {
211243 return {
212244 ...this . baseApiParams ,
213245 ...params1 ,
@@ -220,7 +252,9 @@ export class HttpClient<SecurityDataType = unknown> {
220252 } ;
221253 }
222254
223- protected createAbortSignal = ( cancelToken : CancelToken ) : AbortSignal | undefined => {
255+ protected createAbortSignal = (
256+ cancelToken : CancelToken ,
257+ ) : AbortSignal | undefined => {
224258 if ( this . abortControllers . has ( cancelToken ) ) {
225259 const abortController = this . abortControllers . get ( cancelToken ) ;
226260 if ( abortController ) {
@@ -264,22 +298,34 @@ export class HttpClient<SecurityDataType = unknown> {
264298 const payloadFormatter = this . contentFormatters [ type || ContentType . Json ] ;
265299 const responseFormat = format || requestParams . format ;
266300
267- return this . customFetch ( `${ baseUrl || this . baseUrl || "" } ${ path } ${ queryString ? `?${ queryString } ` : "" } ` , {
268- ...requestParams ,
269- headers : {
270- ...( requestParams . headers || { } ) ,
271- ...( type && type !== ContentType . FormData ? { "Content-Type" : type } : { } ) ,
301+ return this . customFetch (
302+ `${ baseUrl || this . baseUrl || "" } ${ path } ${ queryString ? `?${ queryString } ` : "" } ` ,
303+ {
304+ ...requestParams ,
305+ headers : {
306+ ...( requestParams . headers || { } ) ,
307+ ...( type && type !== ContentType . FormData
308+ ? { "Content-Type" : type }
309+ : { } ) ,
310+ } ,
311+ signal :
312+ ( cancelToken
313+ ? this . createAbortSignal ( cancelToken )
314+ : requestParams . signal ) || null ,
315+ body :
316+ typeof body === "undefined" || body === null
317+ ? null
318+ : payloadFormatter ( body ) ,
272319 } ,
273- signal : ( cancelToken ? this . createAbortSignal ( cancelToken ) : requestParams . signal ) || null ,
274- body : typeof body === "undefined" || body === null ? null : payloadFormatter ( body ) ,
275- } ) . then ( async ( response ) => {
276- const r = response . clone ( ) as HttpResponse < T , E > ;
320+ ) . then ( async ( response ) => {
321+ const r = response as HttpResponse < T , E > ;
277322 r . data = null as unknown as T ;
278323 r . error = null as unknown as E ;
279324
325+ const responseToParse = responseFormat ? response . clone ( ) : response ;
280326 const data = ! responseFormat
281327 ? r
282- : await response [ responseFormat ] ( )
328+ : await responseToParse [ responseFormat ] ( )
283329 . then ( ( data ) => {
284330 if ( r . ok ) {
285331 r . data = data ;
@@ -307,12 +353,14 @@ export class HttpClient<SecurityDataType = unknown> {
307353 * @title RealWorld Conduit API
308354 * @version 1.0.0
309355 * @license MIT License (https://opensource.org/licenses/MIT)
310- * @baseUrl https://api.realworld.io /api
311- * @contact RealWorld (https://www. realworld.how )
356+ * @baseUrl https://api.realworld.show /api
357+ * @contact RealWorld (https://realworld-docs.netlify.app/ )
312358 *
313359 * Conduit API documentation
314360 */
315- export class Api < SecurityDataType extends unknown > extends HttpClient < SecurityDataType > {
361+ export class Api <
362+ SecurityDataType extends unknown ,
363+ > extends HttpClient < SecurityDataType > {
316364 users = {
317365 /**
318366 * @description Login for existing user
@@ -509,7 +557,19 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
509557 ) =>
510558 this . request <
511559 {
512- articles : Article [ ] ;
560+ articles : {
561+ slug : string ;
562+ title : string ;
563+ description : string ;
564+ tagList : string [ ] ;
565+ /** @format date-time */
566+ createdAt : string ;
567+ /** @format date-time */
568+ updatedAt : string ;
569+ favorited : boolean ;
570+ favoritesCount : number ;
571+ author : Profile ;
572+ } [ ] ;
513573 articlesCount : number ;
514574 } ,
515575 GenericErrorModel
@@ -553,7 +613,19 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
553613 ) =>
554614 this . request <
555615 {
556- articles : Article [ ] ;
616+ articles : {
617+ slug : string ;
618+ title : string ;
619+ description : string ;
620+ tagList : string [ ] ;
621+ /** @format date-time */
622+ createdAt : string ;
623+ /** @format date-time */
624+ updatedAt : string ;
625+ favorited : boolean ;
626+ favoritesCount : number ;
627+ author : Profile ;
628+ } [ ] ;
557629 articlesCount : number ;
558630 } ,
559631 GenericErrorModel
@@ -716,7 +788,11 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
716788 * @request DELETE:/articles/{slug}/comments/{id}
717789 * @secure
718790 */
719- deleteArticleComment : ( slug : string , id : number , params : RequestParams = { } ) =>
791+ deleteArticleComment : (
792+ slug : string ,
793+ id : number ,
794+ params : RequestParams = { } ,
795+ ) =>
720796 this . request < any , GenericErrorModel > ( {
721797 path : `/articles/${ slug } /comments/${ id } ` ,
722798 method : "DELETE" ,
0 commit comments