Skip to content

Commit 80903b2

Browse files
Merge pull request #161 from openapi-ui/main
fix: fix npx default params lose
2 parents 58677fc + 5230b8d commit 80903b2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.changeset/sour-berries-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
fix: fix npx default params lose

src/bin/openapi.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env node
22
import { program } from 'commander';
3+
import { pickBy } from 'lodash';
34
import { join } from 'path';
45

56
import * as pkg from '../../package.json';
6-
import { generateService } from '../index';
7+
import { GenerateServiceProps, generateService } from '../index';
78

89
const params = program
910
.name('openapi')
@@ -95,7 +96,7 @@ async function run() {
9596
const input = getPath(params.input as string);
9697
const output = getPath(params.output as string);
9798

98-
await generateService({
99+
const options: GenerateServiceProps = {
99100
schemaPath: input,
100101
serversPath: output,
101102
requestLibPath: params.requestLibPath as string,
@@ -120,7 +121,14 @@ async function run() {
120121
isOnlyGenTypeScriptType:
121122
JSON.parse(params.isOnlyGenTypeScriptType as string) === true,
122123
isCamelCase: JSON.parse(params.isCamelCase as string) === true,
123-
});
124+
};
125+
126+
await generateService(
127+
pickBy(
128+
options,
129+
(value) => value !== null && value !== undefined && value !== ''
130+
) as GenerateServiceProps
131+
);
124132
process.exit(0);
125133
} catch (error) {
126134
console.error('this is error: ', error);

0 commit comments

Comments
 (0)