@@ -25,6 +25,11 @@ const generateTemplatesCommand = defineCommand({
25
25
"clean output folder before generate template. WARNING: May cause data loss" ,
26
26
default : templateGenBaseConfig . cleanOutput ,
27
27
} ,
28
+ debug : {
29
+ type : "boolean" ,
30
+ description : "additional information about processes inside this tool" ,
31
+ default : templateGenBaseConfig . debug ,
32
+ } ,
28
33
"http-client" : {
29
34
type : "string" ,
30
35
description : `http client type (possible values: ${ Object . values (
@@ -56,11 +61,6 @@ const generateTemplatesCommand = defineCommand({
56
61
description : "Output only errors to console" ,
57
62
default : templateGenBaseConfig . silent ,
58
63
} ,
59
- debug : {
60
- type : "boolean" ,
61
- description : "additional information about processes inside this tool" ,
62
- default : templateGenBaseConfig . debug ,
63
- } ,
64
64
} ,
65
65
run : async ( { args } ) => {
66
66
await generateTemplates ( {
@@ -83,80 +83,86 @@ const generateCommand = defineCommand({
83
83
description : packageJson . description ,
84
84
} ,
85
85
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 ,
97
90
} ,
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 ,
103
95
} ,
104
- templates : {
96
+ "api-class-name" : {
105
97
type : "string" ,
106
- alias : "t " ,
107
- description : "path to folder containing templates" ,
98
+ description : "name of the api class " ,
99
+ default : codeGenBaseConfig . apiClassName ,
108
100
} ,
109
- "default-as-success" : {
101
+ axios : {
110
102
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 ,
115
105
} ,
116
- responses : {
106
+ "clean-output" : {
117
107
type : "boolean" ,
118
- alias : "r" ,
119
108
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 ,
122
111
} ,
123
- "union-enums" : {
112
+ client : {
124
113
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 ,
127
116
} ,
128
- "add-readonly" : {
117
+ "custom-config" : {
118
+ type : "string" ,
119
+ description : "custom config: primitiveTypeConstructs, hooks, ... " ,
120
+ } ,
121
+ debug : {
129
122
type : "boolean" ,
130
- description : "generate readonly properties " ,
131
- default : codeGenBaseConfig . addReadonly ,
123
+ description : "additional information about processes inside this tool " ,
124
+ default : codeGenBaseConfig . debug ,
132
125
} ,
133
- "route-types " : {
126
+ "default-as-success " : {
134
127
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 ,
137
132
} ,
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" : {
139
139
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 ,
142
142
} ,
143
143
"enum-names-as-values" : {
144
144
type : "boolean" ,
145
145
description :
146
146
"use values in 'x-enumNames' as enum values (not only as keys)" ,
147
147
default : codeGenBaseConfig . enumNamesAsValues ,
148
148
} ,
149
- "extract-request-params " : {
149
+ "extract-enums " : {
150
150
type : "boolean" ,
151
151
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 ,
154
154
} ,
155
155
"extract-request-body" : {
156
156
type : "boolean" ,
157
157
description : "extract request body type to data contract" ,
158
158
default : codeGenBaseConfig . extractRequestBody ,
159
159
} ,
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
+ } ,
160
166
"extract-response-body" : {
161
167
type : "boolean" ,
162
168
description : "extract response body type to data contract" ,
@@ -172,57 +178,98 @@ const generateCommand = defineCommand({
172
178
description : "extract all responses described in /components/responses" ,
173
179
default : codeGenBaseConfig . extractResponses ,
174
180
} ,
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
+ } ,
175
197
modular : {
176
198
type : "boolean" ,
177
199
description :
178
200
"generate separated files for http client, data contracts, and routes" ,
179
201
default : codeGenBaseConfig . modular ,
180
202
} ,
181
- js : {
203
+ "module-name-first-tag" : {
182
204
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 ,
185
207
} ,
186
208
"module-name-index" : {
187
209
type : "string" ,
188
210
description :
189
211
"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)" ,
190
212
default : codeGenBaseConfig . moduleNameIndex . toString ( ) ,
191
213
} ,
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 : {
193
227
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 ,
196
230
} ,
197
- axios : {
231
+ path : {
232
+ type : "string" ,
233
+ alias : "p" ,
234
+ description : "path/url to swagger scheme" ,
235
+ required : true ,
236
+ } ,
237
+ responses : {
198
238
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 ,
201
243
} ,
202
- "unwrap-response-data " : {
244
+ "route-types " : {
203
245
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 ,
206
248
} ,
207
- "disable-throw-on-error" : {
249
+ silent : {
208
250
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 ,
211
253
} ,
212
254
"single-http-client" : {
213
255
type : "boolean" ,
214
256
description : "Ability to send HttpClient instance to Api constructor" ,
215
257
default : codeGenBaseConfig . singleHttpClient ,
216
258
} ,
217
- silent : {
259
+ "sort-routes" : {
218
260
type : "boolean" ,
219
- description : "Output only errors to console " ,
220
- default : codeGenBaseConfig . silent ,
261
+ description : "sort routes in alphabetical order " ,
262
+ default : codeGenBaseConfig . sortRoutes ,
221
263
} ,
222
- "default-response" : {
264
+ "sort-types" : {
265
+ type : "boolean" ,
266
+ description : "sort fields and types" ,
267
+ default : codeGenBaseConfig . sortTypes ,
268
+ } ,
269
+ templates : {
223
270
type : "string" ,
224
- description : "default type for empty response schema " ,
225
- default : codeGenBaseConfig . defaultResponseType ,
271
+ alias : "t " ,
272
+ description : "path to folder containing templates" ,
226
273
} ,
227
274
"type-prefix" : {
228
275
type : "string" ,
@@ -234,51 +281,15 @@ const generateCommand = defineCommand({
234
281
description : "data contract name suffix" ,
235
282
default : codeGenBaseConfig . typeSuffix ,
236
283
} ,
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" : {
269
285
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 ,
273
288
} ,
274
- "sort-routes " : {
289
+ "unwrap-response-data " : {
275
290
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 ,
282
293
} ,
283
294
} ,
284
295
run : async ( { args } ) => {
0 commit comments