11import { resolve } from 'path' ;
22
33import type { Client } from '../client/interfaces/Client' ;
4- import { HttpClient } from '../HttpClient' ;
5- import { Indent } from '../Indent' ;
4+ import type { HttpClient } from '../HttpClient' ;
5+ import type { Indent } from '../Indent' ;
66import { copyFile , exists , writeFile } from './fileSystem' ;
77import { formatIndentation as i } from './formatIndentation' ;
8+ import { getHttpRequestName } from './getHttpRequestName' ;
89import { isDefined } from './isDefined' ;
9- import { Templates } from './registerHandlebarTemplates' ;
10+ import type { Templates } from './registerHandlebarTemplates' ;
1011
1112/**
1213 * Generate OpenAPI core files, this includes the basic boilerplate code to handle requests.
@@ -26,12 +27,13 @@ export const writeClientCore = async (
2627 clientName ?: string ,
2728 request ?: string
2829) : Promise < void > => {
30+ const httpRequest = getHttpRequestName ( httpClient ) ;
2931 const context = {
3032 httpClient,
3133 clientName,
34+ httpRequest,
3235 server : client . server ,
3336 version : client . version ,
34- httpRequest : 'XHRHttpRequest' ,
3537 } ;
3638
3739 await writeFile ( resolve ( outputPath , 'OpenAPI.ts' ) , i ( templates . core . settings ( context ) , indent ) ) ;
@@ -43,7 +45,7 @@ export const writeClientCore = async (
4345
4446 if ( isDefined ( clientName ) ) {
4547 await writeFile ( resolve ( outputPath , 'BaseHttpRequest.ts' ) , i ( templates . core . baseHttpRequest ( context ) , indent ) ) ;
46- await writeFile ( resolve ( outputPath , 'XHRHttpRequest .ts' ) , i ( templates . core . httpRequest ( context ) , indent ) ) ;
48+ await writeFile ( resolve ( outputPath , ` ${ httpRequest } .ts` ) , i ( templates . core . httpRequest ( context ) , indent ) ) ;
4749 }
4850
4951 if ( request ) {
0 commit comments