@@ -25,6 +25,11 @@ const generateTemplatesCommand = defineCommand({
2525 "clean output folder before generate template. WARNING: May cause data loss" ,
2626 default : templateGenBaseConfig . cleanOutput ,
2727 } ,
28+ debug : {
29+ type : "boolean" ,
30+ description : "additional information about processes inside this tool" ,
31+ default : templateGenBaseConfig . debug ,
32+ } ,
2833 "http-client" : {
2934 type : "string" ,
3035 description : `http client type (possible values: ${ Object . values (
@@ -56,11 +61,6 @@ const generateTemplatesCommand = defineCommand({
5661 description : "Output only errors to console" ,
5762 default : templateGenBaseConfig . silent ,
5863 } ,
59- debug : {
60- type : "boolean" ,
61- description : "additional information about processes inside this tool" ,
62- default : templateGenBaseConfig . debug ,
63- } ,
6464 } ,
6565 run : async ( { args } ) => {
6666 await generateTemplates ( {
@@ -83,80 +83,86 @@ const generateCommand = defineCommand({
8383 description : packageJson . description ,
8484 } ,
8585 args : {
86- path : {
87- type : "string" ,
88- alias : "p" ,
89- description : "path/url to swagger scheme" ,
90- required : true ,
91- } ,
92- output : {
93- type : "string" ,
94- alias : "o" ,
95- description : "output path of typescript api file" ,
96- default : "./" ,
86+ "add-readonly" : {
87+ type : "boolean" ,
88+ description : "generate readonly properties" ,
89+ default : codeGenBaseConfig . addReadonly ,
9790 } ,
98- name : {
99- type : "string" ,
100- alias : "n" ,
101- description : "name of output typescript api file" ,
102- default : codeGenBaseConfig . fileName ,
91+ "another-array-type" : {
92+ type : "boolean" ,
93+ description : "generate array types as Array<Type> (by default Type[])" ,
94+ default : codeGenBaseConfig . anotherArrayType ,
10395 } ,
104- templates : {
96+ "api-class-name" : {
10597 type : "string" ,
106- alias : "t " ,
107- description : "path to folder containing templates" ,
98+ description : "name of the api class " ,
99+ default : codeGenBaseConfig . apiClassName ,
108100 } ,
109- "default-as-success" : {
101+ axios : {
110102 type : "boolean" ,
111- alias : "d" ,
112- description :
113- 'use "default" response status code as success response too. some swagger schemas use "default" response status code as success response type by default.' ,
114- default : codeGenBaseConfig . defaultResponseAsSuccess ,
103+ description : "generate axios http client" ,
104+ default : false ,
115105 } ,
116- responses : {
106+ "clean-output" : {
117107 type : "boolean" ,
118- alias : "r" ,
119108 description :
120- "generate additional information about request responses also add typings for bad responses " ,
121- default : codeGenBaseConfig . generateResponses ,
109+ "clean output folder before generate api. WARNING: May cause data loss " ,
110+ default : codeGenBaseConfig . cleanOutput ,
122111 } ,
123- "union-enums" : {
112+ client : {
124113 type : "boolean" ,
125- description : 'generate all "enum" types as union types (T1 | T2 | TN)' ,
126- default : codeGenBaseConfig . generateUnionEnums ,
114+ description : "do not generate an API class" ,
115+ default : codeGenBaseConfig . generateClient ,
127116 } ,
128- "add-readonly" : {
117+ "custom-config" : {
118+ type : "string" ,
119+ description : "custom config: primitiveTypeConstructs, hooks, ... " ,
120+ } ,
121+ debug : {
129122 type : "boolean" ,
130- description : "generate readonly properties " ,
131- default : codeGenBaseConfig . addReadonly ,
123+ description : "additional information about processes inside this tool " ,
124+ default : codeGenBaseConfig . debug ,
132125 } ,
133- "route-types " : {
126+ "default-as-success " : {
134127 type : "boolean" ,
135- description : "generate type definitions for API routes" ,
136- default : codeGenBaseConfig . generateRouteTypes ,
128+ alias : "d" ,
129+ description :
130+ 'use "default" response status code as success response too. some swagger schemas use "default" response status code as success response type by default.' ,
131+ default : codeGenBaseConfig . defaultResponseAsSuccess ,
137132 } ,
138- client : {
133+ "default-response" : {
134+ type : "string" ,
135+ description : "default type for empty response schema" ,
136+ default : codeGenBaseConfig . defaultResponseType ,
137+ } ,
138+ "disable-throw-on-error" : {
139139 type : "boolean" ,
140- description : "do not generate an API class " ,
141- default : codeGenBaseConfig . generateClient ,
140+ description : "Do not throw an error when response.ok is not true " ,
141+ default : codeGenBaseConfig . disableThrowOnError ,
142142 } ,
143143 "enum-names-as-values" : {
144144 type : "boolean" ,
145145 description :
146146 "use values in 'x-enumNames' as enum values (not only as keys)" ,
147147 default : codeGenBaseConfig . enumNamesAsValues ,
148148 } ,
149- "extract-request-params " : {
149+ "extract-enums " : {
150150 type : "boolean" ,
151151 description :
152- "extract request params to data contract (Also combine path params and query params into one object) " ,
153- default : codeGenBaseConfig . extractRequestParams ,
152+ "extract all enums from inline interface/type content to typescript enum construction " ,
153+ default : codeGenBaseConfig . extractEnums ,
154154 } ,
155155 "extract-request-body" : {
156156 type : "boolean" ,
157157 description : "extract request body type to data contract" ,
158158 default : codeGenBaseConfig . extractRequestBody ,
159159 } ,
160+ "extract-request-params" : {
161+ type : "boolean" ,
162+ description :
163+ "extract request params to data contract (Also combine path params and query params into one object)" ,
164+ default : codeGenBaseConfig . extractRequestParams ,
165+ } ,
160166 "extract-response-body" : {
161167 type : "boolean" ,
162168 description : "extract response body type to data contract" ,
@@ -172,57 +178,98 @@ const generateCommand = defineCommand({
172178 description : "extract all responses described in /components/responses" ,
173179 default : codeGenBaseConfig . extractResponses ,
174180 } ,
181+ "generate-union-enums" : {
182+ type : "boolean" ,
183+ description : 'generate all "enum" types as union types (T1 | T2 | TN)' ,
184+ default : codeGenBaseConfig . generateUnionEnums ,
185+ } ,
186+ "http-client" : {
187+ type : "string" ,
188+ description : `http client type (possible values: ${ Object . values (
189+ HTTP_CLIENT ,
190+ ) } )`,
191+ } ,
192+ js : {
193+ type : "boolean" ,
194+ description : "generate js api module with declaration file" ,
195+ default : codeGenBaseConfig . toJS ,
196+ } ,
175197 modular : {
176198 type : "boolean" ,
177199 description :
178200 "generate separated files for http client, data contracts, and routes" ,
179201 default : codeGenBaseConfig . modular ,
180202 } ,
181- js : {
203+ "module-name-first-tag" : {
182204 type : "boolean" ,
183- description : "generate js api module with declaration file " ,
184- default : codeGenBaseConfig . toJS ,
205+ description : "splits routes based on the first tag " ,
206+ default : codeGenBaseConfig . moduleNameFirstTag ,
185207 } ,
186208 "module-name-index" : {
187209 type : "string" ,
188210 description :
189211 "determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)" ,
190212 default : codeGenBaseConfig . moduleNameIndex . toString ( ) ,
191213 } ,
192- "module-name-first-tag" : {
214+ name : {
215+ type : "string" ,
216+ alias : "n" ,
217+ description : "name of output typescript api file" ,
218+ default : codeGenBaseConfig . fileName ,
219+ } ,
220+ output : {
221+ type : "string" ,
222+ alias : "o" ,
223+ description : "output path of typescript api file" ,
224+ default : "./" ,
225+ } ,
226+ patch : {
193227 type : "boolean" ,
194- description : "splits routes based on the first tag " ,
195- default : codeGenBaseConfig . moduleNameFirstTag ,
228+ description : "fix up small errors in the swagger source definition " ,
229+ default : codeGenBaseConfig . patch ,
196230 } ,
197- axios : {
231+ path : {
232+ type : "string" ,
233+ alias : "p" ,
234+ description : "path/url to swagger scheme" ,
235+ required : true ,
236+ } ,
237+ responses : {
198238 type : "boolean" ,
199- description : "generate axios http client" ,
200- default : false ,
239+ alias : "r" ,
240+ description :
241+ "generate additional information about request responses also add typings for bad responses" ,
242+ default : codeGenBaseConfig . generateResponses ,
201243 } ,
202- "unwrap-response-data " : {
244+ "route-types " : {
203245 type : "boolean" ,
204- description : "unwrap the data item from the response " ,
205- default : codeGenBaseConfig . unwrapResponseData ,
246+ description : "generate type definitions for API routes " ,
247+ default : codeGenBaseConfig . generateRouteTypes ,
206248 } ,
207- "disable-throw-on-error" : {
249+ silent : {
208250 type : "boolean" ,
209- description : "Do not throw an error when response.ok is not true " ,
210- default : codeGenBaseConfig . disableThrowOnError ,
251+ description : "Output only errors to console " ,
252+ default : codeGenBaseConfig . silent ,
211253 } ,
212254 "single-http-client" : {
213255 type : "boolean" ,
214256 description : "Ability to send HttpClient instance to Api constructor" ,
215257 default : codeGenBaseConfig . singleHttpClient ,
216258 } ,
217- silent : {
259+ "sort-routes" : {
218260 type : "boolean" ,
219- description : "Output only errors to console " ,
220- default : codeGenBaseConfig . silent ,
261+ description : "sort routes in alphabetical order " ,
262+ default : codeGenBaseConfig . sortRoutes ,
221263 } ,
222- "default-response" : {
264+ "sort-types" : {
265+ type : "boolean" ,
266+ description : "sort fields and types" ,
267+ default : codeGenBaseConfig . sortTypes ,
268+ } ,
269+ templates : {
223270 type : "string" ,
224- description : "default type for empty response schema " ,
225- default : codeGenBaseConfig . defaultResponseType ,
271+ alias : "t " ,
272+ description : "path to folder containing templates" ,
226273 } ,
227274 "type-prefix" : {
228275 type : "string" ,
@@ -234,51 +281,15 @@ const generateCommand = defineCommand({
234281 description : "data contract name suffix" ,
235282 default : codeGenBaseConfig . typeSuffix ,
236283 } ,
237- "clean-output" : {
238- type : "boolean" ,
239- description :
240- "clean output folder before generate api. WARNING: May cause data loss" ,
241- default : codeGenBaseConfig . cleanOutput ,
242- } ,
243- "api-class-name" : {
244- type : "string" ,
245- description : "name of the api class" ,
246- default : codeGenBaseConfig . apiClassName ,
247- } ,
248- patch : {
249- type : "boolean" ,
250- description : "fix up small errors in the swagger source definition" ,
251- default : codeGenBaseConfig . patch ,
252- } ,
253- debug : {
254- type : "boolean" ,
255- description : "additional information about processes inside this tool" ,
256- default : codeGenBaseConfig . debug ,
257- } ,
258- "another-array-type" : {
259- type : "boolean" ,
260- description : "generate array types as Array<Type> (by default Type[])" ,
261- default : codeGenBaseConfig . anotherArrayType ,
262- } ,
263- "sort-types" : {
264- type : "boolean" ,
265- description : "sort fields and types" ,
266- default : codeGenBaseConfig . sortTypes ,
267- } ,
268- "extract-enums" : {
284+ "union-enums" : {
269285 type : "boolean" ,
270- description :
271- "extract all enums from inline interface/type content to typescript enum construction" ,
272- default : codeGenBaseConfig . extractEnums ,
286+ description : 'generate all "enum" types as union types (T1 | T2 | TN)' ,
287+ default : codeGenBaseConfig . generateUnionEnums ,
273288 } ,
274- "sort-routes " : {
289+ "unwrap-response-data " : {
275290 type : "boolean" ,
276- description : "sort routes in alphabetical order" ,
277- default : codeGenBaseConfig . sortRoutes ,
278- } ,
279- "custom-config" : {
280- type : "string" ,
281- description : "custom config: primitiveTypeConstructs, hooks, ... " ,
291+ description : "unwrap the data item from the response" ,
292+ default : codeGenBaseConfig . unwrapResponseData ,
282293 } ,
283294 } ,
284295 run : async ( { args } ) => {
0 commit comments