@@ -13,19 +13,16 @@ const params = program
1313 . name ( 'openapi' )
1414 . usage ( '[options]' )
1515 . version ( pkg . version )
16- // .requiredOption(
17- // '-i, --input <string>',
18- // 'OpenAPI specification, can be a path, url (required)'
19- // )
20- // .requiredOption('-o, --output <string>', 'output directory (required)')
2116 . option ( '-i, --input <string>' , 'OpenAPI specification, can be a path, url' )
2217 . option ( '-o, --output <string>' , 'output directory' )
23- . option ( '-cfn, --configFileName <configFileName>' , 'config file name' )
24- . option ( '-cfp, --configFilePath <configFilePath>' , 'config file path' )
18+ . option ( '-cfn, --configFileName <string>' , 'config file name' )
19+ . option ( '-cfp, --configFilePath <string>' , 'config file path' )
20+ . option ( '-u, --uniqueKey <string>' , 'unique key' )
2521 . option (
2622 '--requestLibPath <string>' ,
2723 'custom request lib path, for example: "@/request", "node-fetch" (default: "axios")'
2824 )
25+ . option ( '-f, --full <boolean>' , 'full replacement' , true )
2926 . option ( '--enableLogging <boolean>' , 'open the log' , false )
3027 . option (
3128 '--priorityRule <string>' ,
@@ -94,8 +91,6 @@ const params = program
9491 'parse enum description to generate enum label' ,
9592 false
9693 )
97- . option ( '-u, --unique-key <uniqueKey>' , 'unique key' )
98- . option ( '-f, --full <boolean>' , 'full replacement' , false )
9994 . parse ( process . argv )
10095 . opts ( ) ;
10196
@@ -116,6 +111,7 @@ const baseGenerate = (_params_: OptionValues): GenerateServiceProps => {
116111 schemaPath : input ,
117112 serversPath : output ,
118113 requestLibPath : _params_ . requestLibPath as string ,
114+ full : JSON . parse ( _params_ . full as string ) === true ,
119115 enableLogging : JSON . parse ( _params_ . enableLogging as string ) === true ,
120116 priorityRule : _params_ . priorityRule as IPriorityRule ,
121117 includeTags : _params_ . includeTags as string [ ] ,
@@ -141,6 +137,7 @@ const baseGenerate = (_params_: OptionValues): GenerateServiceProps => {
141137 isSupportParseEnumDesc :
142138 JSON . parse ( _params_ . isSupportParseEnumDesc as string ) === true ,
143139 } ;
140+
144141 return options ;
145142} ;
146143
@@ -155,33 +152,40 @@ async function run() {
155152 ) ;
156153 process . exit ( 0 ) ;
157154 }
155+
158156 const cnf = await readConfig < GenerateServiceProps | GenerateServiceProps [ ] > ( {
159157 fallbackName : 'openapi-ts-request' ,
160158 filePath : params . configFilePath as string ,
161159 fileName : params . configFileName as undefined ,
162160 } ) ;
161+
163162 try {
164163 if ( cnf ) {
165164 const tasks = [ ] ;
166165 let configs : GenerateServiceProps [ ] = Array . isArray ( cnf ) ? cnf : [ cnf ] ;
166+
167167 if ( params . uniqueKey ) {
168168 configs = configs . filter (
169169 ( config ) => config . uniqueKey === params . uniqueKey
170170 ) ;
171171 }
172+
172173 for ( const config of configs ) {
173174 tasks . push ( generateService ( config ) ) ;
174175 }
176+
175177 const results = await Promise . allSettled ( tasks ) ;
176178 const errors : PromiseRejectedResult [ ] = results . filter (
177179 ( result ) => result . status === 'rejected'
178180 ) ;
179181 let errorMsg = '' ;
182+
180183 for ( let i = 0 ; i < errors . length ; i ++ ) {
181184 const error = errors [ i ] ;
182185 const cnf = configs [ i ] ;
183186 errorMsg += `${ cnf . uniqueKey } ${ cnf . uniqueKey && ':' } ${ error . reason } \n` ;
184187 }
188+
185189 if ( errorMsg ) {
186190 logError ( errorMsg ) ;
187191 process . exit ( 1 ) ;
@@ -193,6 +197,7 @@ async function run() {
193197 ) ;
194198 process . exit ( 1 ) ;
195199 }
200+
196201 const options = baseGenerate ( params ) ;
197202 await generateService (
198203 pickBy (
0 commit comments