11import { HttpClient } from './HttpClient' ;
2+ import { Indent } from './Indent' ;
23import { parse as parseV2 } from './openApi/v2' ;
34import { parse as parseV3 } from './openApi/v3' ;
45import { getOpenApiSpec } from './utils/getOpenApiSpec' ;
@@ -9,17 +10,20 @@ import { registerHandlebarTemplates } from './utils/registerHandlebarTemplates';
910import { writeClient } from './utils/writeClient' ;
1011
1112export { HttpClient } from './HttpClient' ;
13+ export { Indent } from './Indent' ;
1214
1315export type Options = {
1416 input : string | Record < string , any > ;
1517 output : string ;
1618 httpClient ?: HttpClient ;
19+ clientName ?: string ;
1720 useOptions ?: boolean ;
1821 useUnionTypes ?: boolean ;
1922 exportCore ?: boolean ;
2023 exportServices ?: boolean ;
2124 exportModels ?: boolean ;
2225 exportSchemas ?: boolean ;
26+ indent ?: Indent ;
2327 postfix ?: string ;
2428 request ?: string ;
2529 write ?: boolean ;
@@ -32,30 +36,34 @@ export type Options = {
3236 * @param input The relative location of the OpenAPI spec
3337 * @param output The relative location of the output directory
3438 * @param httpClient The selected httpClient (fetch, xhr, node or axios)
39+ * @param clientName Custom client class name
3540 * @param useOptions Use options or arguments functions
3641 * @param useUnionTypes Use union types instead of enums
37- * @param exportCore: Generate core client classes
38- * @param exportServices: Generate services
39- * @param exportModels: Generate models
40- * @param exportSchemas: Generate schemas
41- * @param postfix: Service name postfix
42- * @param request: Path to custom request file
42+ * @param exportCore Generate core client classes
43+ * @param exportServices Generate services
44+ * @param exportModels Generate models
45+ * @param exportSchemas Generate schemas
46+ * @param indent Indentation options (4, 2 or tab)
47+ * @param postfix Service name postfix
48+ * @param request Path to custom request file
4349 * @param write Write the files to disk (true or false)
4450 */
45- export async function generate ( {
51+ export const generate = async ( {
4652 input,
4753 output,
4854 httpClient = HttpClient . FETCH ,
55+ clientName,
4956 useOptions = false ,
5057 useUnionTypes = false ,
5158 exportCore = true ,
5259 exportServices = true ,
5360 exportModels = true ,
5461 exportSchemas = false ,
62+ indent = Indent . SPACE_4 ,
5563 postfix = 'Service' ,
5664 request,
5765 write = true ,
58- } : Options ) : Promise < void > {
66+ } : Options ) : Promise < void > => {
5967 const openApi = isString ( input ) ? await getOpenApiSpec ( input ) : input ;
6068 const openApiVersion = getOpenApiVersion ( openApi ) ;
6169 const templates = registerHandlebarTemplates ( {
@@ -80,7 +88,9 @@ export async function generate({
8088 exportServices ,
8189 exportModels ,
8290 exportSchemas ,
91+ indent ,
8392 postfix ,
93+ clientName ,
8494 request
8595 ) ;
8696 break ;
@@ -101,13 +111,15 @@ export async function generate({
101111 exportServices ,
102112 exportModels ,
103113 exportSchemas ,
114+ indent ,
104115 postfix ,
116+ clientName ,
105117 request
106118 ) ;
107119 break ;
108120 }
109121 }
110- }
122+ } ;
111123
112124export default {
113125 HttpClient,
0 commit comments