@@ -3,9 +3,11 @@ import { resolve } from 'path';
33import type { Client } from '../client/interfaces/Client' ;
44import { HttpClient } from '../HttpClient' ;
55import { Indent } from '../Indent' ;
6- import { copyFile , exists , writeFile } from './fileSystem' ;
6+ import { copyFile , exists , mkdir , writeFile } from './fileSystem' ;
77import { formatIndentation as i } from './formatIndentation' ;
8+ import { isDefined } from './isDefined' ;
89import { Templates } from './registerHandlebarTemplates' ;
10+ import { writeClientClass } from './writeClientClass' ;
911
1012/**
1113 * Generate OpenAPI core files, this includes the basic boilerplate code to handle requests.
@@ -22,12 +24,15 @@ export async function writeClientCore(
2224 outputPath : string ,
2325 httpClient : HttpClient ,
2426 indent : Indent ,
27+ clientName ?: string ,
2528 request ?: string
2629) : Promise < void > {
2730 const context = {
2831 httpClient,
32+ clientName,
2933 server : client . server ,
3034 version : client . version ,
35+ httpRequest : 'XHRHttpRequest' ,
3136 } ;
3237
3338 await writeFile ( resolve ( outputPath , 'OpenAPI.ts' ) , i ( templates . core . settings ( context ) , indent ) ) ;
@@ -37,6 +42,11 @@ export async function writeClientCore(
3742 await writeFile ( resolve ( outputPath , 'CancelablePromise.ts' ) , i ( templates . core . cancelablePromise ( context ) , indent ) ) ;
3843 await writeFile ( resolve ( outputPath , 'request.ts' ) , i ( templates . core . request ( context ) , indent ) ) ;
3944
45+ if ( isDefined ( clientName ) ) {
46+ await writeFile ( resolve ( outputPath , 'BaseHttpRequest.ts' ) , i ( templates . core . baseHttpRequest ( context ) , indent ) ) ;
47+ await writeFile ( resolve ( outputPath , 'XHRHttpRequest.ts' ) , i ( templates . core . httpRequest ( context ) , indent ) ) ;
48+ }
49+
4050 if ( request ) {
4151 const requestFile = resolve ( process . cwd ( ) , request ) ;
4252 const requestFileExists = await exists ( requestFile ) ;
0 commit comments