@@ -204,7 +204,7 @@ async function generateEndpoints(
204204
205205async function generateApiClientJSDoc (
206206 openApiDocs : OpenAPIV3_1 . Document ,
207- apiTypesFileName : string ,
207+ apiClientFileName : string ,
208208 endpointsFileName : string ,
209209 warningsOutputPath : string ,
210210) {
@@ -238,29 +238,31 @@ async function generateApiClientJSDoc(
238238
239239 const endpointOutputLine : string [ ] = [ ] ;
240240
241- endpointOutputLine . push ( `import type { SwitchCaseResponseType } from '${ toImportPath ( apiTypesFileName ) } ';` ) ;
241+ endpointOutputLine . push ( `import type { SwitchCaseResponseType } from '${ toImportPath ( apiClientFileName ) } ';` ) ;
242242 endpointOutputLine . push ( `import type { Endpoints } from '${ toImportPath ( endpointsFileName ) } ';` ) ;
243243 endpointOutputLine . push ( '' ) ;
244244
245- endpointOutputLine . push ( 'export interface APIClient {' ) ;
245+ endpointOutputLine . push ( `declare module '${ toImportPath ( apiClientFileName ) } ' {` ) ;
246+ endpointOutputLine . push ( ' export interface APIClient {' ) ;
246247 for ( let i = 0 ; i < endpoints . length ; i ++ ) {
247248 const endpoint = endpoints [ i ] ;
248249
249250 endpointOutputLine . push (
250- ' /**' ,
251- ` * ${ endpoint . description . split ( '\n' ) . join ( '\n * ' ) } ` ,
252- ' */' ,
253- ` request<E extends '${ endpoint . path } ', P extends Endpoints[E][\'req\']>(` ,
254- ' endpoint: E,' ,
255- ' params: P,' ,
256- ' credential?: string | null,' ,
257- ' ): Promise<SwitchCaseResponseType<E, P>>;' ,
251+ ' /**' ,
252+ ` * ${ endpoint . description . split ( '\n' ) . join ( '\n * ' ) } ` ,
253+ ' */' ,
254+ ` request<E extends '${ endpoint . path } ', P extends Endpoints[E][\'req\']>(` ,
255+ ' endpoint: E,' ,
256+ ' params: P,' ,
257+ ' credential?: string | null,' ,
258+ ' ): Promise<SwitchCaseResponseType<E, P>>;' ,
258259 ) ;
259260
260261 if ( i < endpoints . length - 1 ) {
261262 endpointOutputLine . push ( '\n' ) ;
262263 }
263264 }
265+ endpointOutputLine . push ( ' }' ) ;
264266 endpointOutputLine . push ( '}' ) ;
265267 endpointOutputLine . push ( '' ) ;
266268
@@ -412,7 +414,7 @@ async function main() {
412414 await generateEndpoints ( openApiDocs , typeFileName , entitiesFileName , endpointFileName ) ;
413415
414416 const apiClientWarningFileName = `${ generatePath } /apiClientJSDoc.ts` ;
415- await generateApiClientJSDoc ( openApiDocs , '../api.types. ts' , endpointFileName , apiClientWarningFileName ) ;
417+ await generateApiClientJSDoc ( openApiDocs , '../api.ts' , endpointFileName , apiClientWarningFileName ) ;
416418}
417419
418420main ( ) ;
0 commit comments