Skip to content

Commit f844024

Browse files
committed
add --exportIndex param
1 parent b9ad91b commit f844024

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

bin/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const params = program
2020
.option('--exportServices <value>', 'Write services to disk', true)
2121
.option('--exportModels <value>', 'Write models to disk', true)
2222
.option('--exportSchemas <value>', 'Write schemas to disk', false)
23+
.option('--exportIndex <value>', 'Write index file to disk (default: exportCore || exportServices || exportModels || exportSchemas)')
2324
.option('--indent <value>', 'Indentation options [4, 2, tabs]', '4')
2425
.option('--postfix <value>', 'Service name postfix', 'Service')
2526
.option('--request <value>', 'Path to custom request file')
@@ -40,6 +41,7 @@ if (OpenAPI) {
4041
exportServices: JSON.parse(params.exportServices) === true,
4142
exportModels: JSON.parse(params.exportModels) === true,
4243
exportSchemas: JSON.parse(params.exportSchemas) === true,
44+
exportIndex: params.exportIndex,
4345
indent: params.indent,
4446
postfix: params.postfix,
4547
request: params.request,

bin/index.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ describe('bin', () => {
3232
'true',
3333
'--exportSchemas',
3434
'true',
35+
'--exportIndex',
36+
'true',
3537
'--indent',
3638
'4',
3739
'--postfix',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type Options = {
2323
exportServices?: boolean;
2424
exportModels?: boolean;
2525
exportSchemas?: boolean;
26+
exportIndex?: boolean;
2627
indent?: Indent;
2728
postfix?: string;
2829
request?: string;
@@ -43,6 +44,7 @@ export type Options = {
4344
* @param exportServices Generate services
4445
* @param exportModels Generate models
4546
* @param exportSchemas Generate schemas
47+
* @param exportSchemas Generate index file
4648
* @param indent Indentation options (4, 2 or tab)
4749
* @param postfix Service name postfix
4850
* @param request Path to custom request file
@@ -59,6 +61,7 @@ export const generate = async ({
5961
exportServices = true,
6062
exportModels = true,
6163
exportSchemas = false,
64+
exportIndex,
6265
indent = Indent.SPACE_4,
6366
postfix = 'Service',
6467
request,
@@ -88,6 +91,7 @@ export const generate = async ({
8891
exportServices,
8992
exportModels,
9093
exportSchemas,
94+
exportIndex,
9195
indent,
9296
postfix,
9397
clientName,
@@ -111,6 +115,7 @@ export const generate = async ({
111115
exportServices,
112116
exportModels,
113117
exportSchemas,
118+
exportIndex,
114119
indent,
115120
postfix,
116121
clientName,

src/utils/writeClient.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe('writeClient', () => {
4747
true,
4848
true,
4949
true,
50+
undefined,
5051
Indent.SPACE_4,
5152
'Service',
5253
'AppClient'

src/utils/writeClient.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { writeClientServices } from './writeClientServices';
2626
* @param exportServices Generate services
2727
* @param exportModels Generate models
2828
* @param exportSchemas Generate schemas
29-
* @param exportSchemas Generate schemas
29+
* @param exportIndex Generate index file
3030
* @param indent Indentation options (4, 2 or tab)
3131
* @param postfix Service name postfix
3232
* @param clientName Custom client class name
@@ -43,6 +43,7 @@ export const writeClient = async (
4343
exportServices: boolean,
4444
exportModels: boolean,
4545
exportSchemas: boolean,
46+
exportIndex: boolean | undefined,
4647
indent: Indent,
4748
postfix: string,
4849
clientName?: string,
@@ -97,7 +98,7 @@ export const writeClient = async (
9798
await writeClientClass(client, templates, outputPath, httpClient, clientName, indent, postfix);
9899
}
99100

100-
if (exportCore || exportServices || exportSchemas || exportModels) {
101+
if (exportIndex ?? (exportCore || exportServices || exportSchemas || exportModels)) {
101102
await mkdir(outputPath);
102103
await writeClientIndex(
103104
client,

0 commit comments

Comments
 (0)