@@ -33,29 +33,20 @@ program
3333 )
3434 . option (
3535 "-r, --responses" ,
36- "generate additional information about request responses\n" +
37- "also add typings for bad responses" ,
36+ "generate additional information about request responses\n" + "also add typings for bad responses" ,
3837 false ,
3938 )
4039 . option ( "--union-enums" , 'generate all "enum" types as union types (T1 | T2 | TN)' , false )
4140 . option ( "--route-types" , "generate type definitions for API routes" , false )
4241 . option ( "--no-client" , "do not generate an API class" , false )
43- . option (
44- "--enum-names-as-values" ,
45- "use values in 'x-enumNames' as enum values (not only as keys)" ,
46- false ,
47- )
42+ . option ( "--enum-names-as-values" , "use values in 'x-enumNames' as enum values (not only as keys)" , false )
4843 . option (
4944 "--extract-request-params" ,
5045 "extract request params to data contract (Also combine path params and query params into one object)" ,
5146 false ,
5247 )
5348 . option ( "--extract-request-body" , "extract request body type to data contract" , false )
54- . option (
55- "--modular" ,
56- "generate separated files for http client, data contracts, and routes" ,
57- false ,
58- )
49+ . option ( "--modular" , "generate separated files for http client, data contracts, and routes" , false )
5950 . option ( "--js" , "generate js api module with declaration file" , false )
6051 . option (
6152 "--module-name-index <number>" ,
@@ -72,11 +63,7 @@ program
7263 . option ( "--default-response <type>" , "default type for empty response schema" , TS_KEYWORDS . VOID )
7364 . option ( "--type-prefix <string>" , "data contract name prefix" , "" )
7465 . option ( "--type-suffix <string>" , "data contract name suffix" , "" )
75- . option (
76- "--clean-output" ,
77- "clean output folder before generate api. WARNING: May cause data loss" ,
78- false ,
79- )
66+ . option ( "--clean-output" , "clean output folder before generate api. WARNING: May cause data loss" , false )
8067 . option ( "--patch" , "fix up small errors in the swagger source definition" , false ) ;
8168
8269program . parse ( process . argv ) ;
@@ -140,4 +127,9 @@ generateApi({
140127 typePrefix,
141128 typeSuffix,
142129 patch : ! ! patch ,
130+ } ) . catch ( ( err ) => {
131+ // NOTE collect all errors on top level and shows to users in any case
132+ console . error ( err ) ;
133+
134+ process . exit ( 1 ) ;
143135} ) ;
0 commit comments