@@ -14,29 +14,29 @@ type ServerMap = {
1414const operationServerMap : ServerMap = { }
1515
1616function setFlattenedQueryParams ( urlSearchParams : URLSearchParams , parameter : any , key = '' ) : void {
17- if ( parameter == null ) return
18- if ( typeof parameter === 'object' ) {
19- if ( Array . isArray ( parameter ) ) {
20- ; ( parameter as any [ ] ) . forEach ( item => setFlattenedQueryParams ( urlSearchParams , item , key ) )
21- } else {
22- Object . keys ( parameter ) . forEach ( currentKey =>
23- setFlattenedQueryParams (
24- urlSearchParams ,
25- parameter [ currentKey ] ,
26- `${ key } ${ key !== '' ? '.' : '' } ${ currentKey } `
27- )
28- )
29- }
17+ if ( parameter == null ) return
18+ if ( typeof parameter === 'object' ) {
19+ if ( Array . isArray ( parameter ) ) {
20+ ; ( parameter as any [ ] ) . forEach ( item => setFlattenedQueryParams ( urlSearchParams , item , key ) )
3021 } else {
31- if ( urlSearchParams . has ( key ) ) urlSearchParams . append ( key , parameter )
32- else urlSearchParams . set ( key , parameter )
22+ Object . keys ( parameter ) . forEach ( currentKey =>
23+ setFlattenedQueryParams (
24+ urlSearchParams ,
25+ parameter [ currentKey ] ,
26+ `${ key } ${ key !== '' ? '.' : '' } ${ currentKey } `
27+ )
28+ )
3329 }
30+ } else {
31+ if ( urlSearchParams . has ( key ) ) urlSearchParams . append ( key , parameter )
32+ else urlSearchParams . set ( key , parameter )
33+ }
3434}
3535
3636const setSearchParams = ( url : URL , ...objects : any [ ] ) => {
37- const searchParams = new URLSearchParams ( url . search )
38- setFlattenedQueryParams ( searchParams , objects )
39- url . search = searchParams . toString ( )
37+ const searchParams = new URLSearchParams ( url . search )
38+ setFlattenedQueryParams ( searchParams , objects )
39+ url . search = searchParams . toString ( )
4040}
4141
4242const toPathString = ( url : URL ) => url . pathname + url . search + url . hash
@@ -47,80 +47,82 @@ const createRequestFunction = (
4747 BASE_PATH : string ,
4848 configuration ?: Configuration
4949) => {
50- return < T = unknown , R = AxiosResponse < T > > (
51- axios : AxiosInstance = globalAxiosInst ,
52- basePath : string = BASE_PATH
53- ) => {
54- const axiosRequestArgs = {
55- ...axiosArgs . options ,
56- url : ( axios . defaults . baseURL ? '' : configuration ?. basePath ?? basePath ) + axiosArgs . url
57- }
58- return axios . request < T , R > ( axiosRequestArgs )
50+ return < T = unknown , R = AxiosResponse < T > > (
51+ axios : AxiosInstance = globalAxiosInst ,
52+ basePath : string = BASE_PATH
53+ ) => {
54+ const axiosRequestArgs = {
55+ ...axiosArgs . options ,
56+ url : ( axios . defaults . baseURL ? '' : configuration ?. basePath ?? basePath ) + axiosArgs . url ,
5957 }
58+ return axios . request < T , R > ( axiosRequestArgs )
59+ }
6060}
6161
6262class BaseAPI {
63- protected configuration : Configuration | undefined
63+ protected configuration : Configuration | undefined
6464
65- constructor (
66- configuration ?: Configuration ,
65+ constructor (
66+ configuration ?: Configuration ,
6767 protected basePath : string = 'http://example' ,
6868 protected axios : AxiosInstance = globalAxios
69- ) {
70- if ( configuration ) {
71- this . configuration = configuration
72- this . basePath = configuration . basePath ?? basePath
73- }
69+ ) {
70+ if ( configuration ) {
71+ this . configuration = configuration
72+ this . basePath = configuration . basePath ?? basePath
7473 }
74+ }
7575}
7676
7777export const DefaultApiAxiosParamCreator = ( configuration ?: Configuration ) => ( {
78- fetchData : async ( options : RawAxiosRequestConfig = { } ) : Promise < RequestArgs > => {
79- const localVarPath = `/data`
80- const localVarUrlObj = new URL ( localVarPath , 'http://example' )
81- let baseOptions
82- if ( configuration ) baseOptions = configuration . baseOptions
83-
84- const localVarRequestOptions = { method : 'GET' , ...baseOptions , ...options }
85- const localVarHeaderParameter = { } as any
86- const localVarQueryParameter = { } as any
87-
88- setSearchParams ( localVarUrlObj , localVarQueryParameter )
89- const headersFromBaseOptions = baseOptions && baseOptions . headers ? baseOptions . headers : { }
90- localVarRequestOptions . headers = {
91- ...localVarHeaderParameter ,
92- ...headersFromBaseOptions ,
93- ...options . headers
94- }
95-
96- return {
97- url : toPathString ( localVarUrlObj ) ,
98- options : localVarRequestOptions
99- }
78+ fetchData : async ( options : RawAxiosRequestConfig = { } ) : Promise < RequestArgs > => {
79+ const localVarPath = `/data`
80+ const localVarUrlObj = new URL ( localVarPath , 'http://example' )
81+ let baseOptions
82+ if ( configuration ) baseOptions = configuration . baseOptions
83+
84+ const localVarRequestOptions = { method : 'GET' , ...baseOptions , ...options }
85+ const localVarHeaderParameter = { } as any
86+ const localVarQueryParameter = { } as any
87+
88+ setSearchParams ( localVarUrlObj , localVarQueryParameter )
89+ const headersFromBaseOptions = baseOptions && baseOptions . headers ? baseOptions . headers : { }
90+ localVarRequestOptions . headers = {
91+ ...localVarHeaderParameter ,
92+ ...headersFromBaseOptions ,
93+ ...options . headers ,
94+ }
95+
96+ return {
97+ url : toPathString ( localVarUrlObj ) ,
98+ options : localVarRequestOptions ,
10099 }
100+ } ,
101101} )
102102
103103export const DefaultApiFp = ( configuration ?: Configuration ) => {
104- const localVarAxiosParamCreator = DefaultApiAxiosParamCreator ( configuration )
105- return {
106- async fetchData (
107- options ?: RawAxiosRequestConfig
108- ) : Promise < ( axios ?: AxiosInstance , basePath ?: string ) => AxiosPromise < string > > {
109- const localVarAxiosArgs = await localVarAxiosParamCreator . fetchData ( options )
110- const localVarOperationServerIndex = configuration ?. serverIndex ?? 0
111- const localVarOperationServerBasePath =
104+ const localVarAxiosParamCreator = DefaultApiAxiosParamCreator ( configuration )
105+ return {
106+ async fetchData (
107+ options ?: RawAxiosRequestConfig
108+ ) : Promise < ( axios ?: AxiosInstance , basePath ?: string ) => AxiosPromise < string > > {
109+ const localVarAxiosArgs = await localVarAxiosParamCreator . fetchData ( options )
110+ const localVarOperationServerIndex = configuration ?. serverIndex ?? 0
111+ const localVarOperationServerBasePath =
112112 operationServerMap [ 'DefaultApi.fetchData' ] ?. [ localVarOperationServerIndex ] ?. url
113- return ( axios , basePath ) =>
114- createRequestFunction ( localVarAxiosArgs , globalAxios , 'http://example' , configuration ) (
115- axios ,
116- localVarOperationServerBasePath || basePath
117- )
118- }
119- }
113+ return ( axios , basePath ) =>
114+ createRequestFunction ( localVarAxiosArgs , globalAxios , 'http://example' , configuration ) (
115+ axios ,
116+ localVarOperationServerBasePath || basePath
117+ )
118+ } ,
119+ }
120120}
121121
122+ export type DefaultApiFp = typeof DefaultApiFp
123+
122124export class DefaultApi extends BaseAPI {
123- fetchData ( options ?: RawAxiosRequestConfig ) {
124- return DefaultApiFp ( this . configuration ) . fetchData ( options ) . then ( request => request ( this . axios , this . basePath ) )
125- }
125+ fetchData ( options ?: RawAxiosRequestConfig ) {
126+ return DefaultApiFp ( this . configuration ) . fetchData ( options ) . then ( request => request ( this . axios , this . basePath ) )
127+ }
126128}
0 commit comments