swagger-typescript-api 13.0.0-experimental-1 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +26 -12
  3. package/cli/constants.js +3 -3
  4. package/cli/execute.js +52 -31
  5. package/cli/index.d.ts +1 -2
  6. package/cli/index.js +18 -17
  7. package/cli/operations/display-help.js +51 -29
  8. package/cli/parse-args.js +3 -3
  9. package/cli/process-option.js +28 -20
  10. package/index.d.ts +113 -8
  11. package/index.js +164 -135
  12. package/package.json +36 -30
  13. package/src/code-formatter.js +28 -13
  14. package/src/code-gen-process.js +367 -259
  15. package/src/commands/generate-templates/configuration.js +2 -2
  16. package/src/commands/generate-templates/index.js +1 -2
  17. package/src/commands/generate-templates/templates-gen-process.js +62 -35
  18. package/src/component-type-name-resolver.js +44 -0
  19. package/src/configuration.js +172 -96
  20. package/src/constants.js +28 -22
  21. package/src/index.js +3 -4
  22. package/src/schema-components-map.js +43 -25
  23. package/src/schema-parser/base-schema-parsers/array.js +43 -0
  24. package/src/schema-parser/base-schema-parsers/complex.js +51 -0
  25. package/src/schema-parser/base-schema-parsers/discriminator.js +304 -0
  26. package/src/schema-parser/base-schema-parsers/enum.js +158 -0
  27. package/src/schema-parser/base-schema-parsers/object.js +105 -0
  28. package/src/schema-parser/base-schema-parsers/primitive.js +63 -0
  29. package/src/schema-parser/complex-schema-parsers/all-of.js +26 -0
  30. package/src/schema-parser/complex-schema-parsers/any-of.js +27 -0
  31. package/src/schema-parser/complex-schema-parsers/not.js +9 -0
  32. package/src/schema-parser/complex-schema-parsers/one-of.js +27 -0
  33. package/src/schema-parser/mono-schema-parser.js +48 -0
  34. package/src/schema-parser/schema-formatters.js +69 -60
  35. package/src/schema-parser/schema-parser-fabric.js +131 -0
  36. package/src/schema-parser/schema-parser.js +234 -425
  37. package/src/schema-parser/schema-utils.js +165 -67
  38. package/src/schema-parser/util/enum-key-resolver.js +26 -0
  39. package/src/schema-routes/schema-routes.js +1222 -0
  40. package/src/schema-routes/util/specific-arg-name-resolver.js +26 -0
  41. package/src/schema-walker.js +93 -0
  42. package/src/swagger-schema-resolver.js +61 -28
  43. package/src/templates-worker.js +240 -0
  44. package/src/translators/javascript.js +83 -0
  45. package/src/translators/translator.js +35 -0
  46. package/src/type-name-formatter.js +43 -22
  47. package/src/util/file-system.js +30 -14
  48. package/src/util/id.js +2 -2
  49. package/src/util/internal-case.js +1 -1
  50. package/src/util/logger.js +46 -20
  51. package/src/util/name-resolver.js +52 -60
  52. package/src/util/object-assign.js +7 -3
  53. package/src/util/pascal-case.js +1 -1
  54. package/src/util/request.js +5 -5
  55. package/src/util/sort-by-property.js +17 -0
  56. package/templates/README.md +17 -17
  57. package/templates/base/README.md +7 -7
  58. package/templates/base/data-contract-jsdoc.ejs +37 -37
  59. package/templates/base/data-contracts.ejs +40 -27
  60. package/templates/base/enum-data-contract.ejs +12 -12
  61. package/templates/base/http-client.ejs +3 -3
  62. package/templates/base/http-clients/axios-http-client.ejs +139 -138
  63. package/templates/base/http-clients/fetch-http-client.ejs +224 -224
  64. package/templates/base/interface-data-contract.ejs +10 -10
  65. package/templates/base/object-field-jsdoc.ejs +28 -28
  66. package/templates/base/route-docs.ejs +30 -30
  67. package/templates/base/route-name.ejs +42 -42
  68. package/templates/base/route-type.ejs +22 -21
  69. package/templates/base/type-data-contract.ejs +15 -15
  70. package/templates/default/README.md +6 -6
  71. package/templates/default/api.ejs +69 -68
  72. package/templates/default/procedure-call.ejs +100 -100
  73. package/templates/default/route-types.ejs +32 -32
  74. package/templates/modular/README.md +6 -6
  75. package/templates/modular/api.ejs +28 -28
  76. package/templates/modular/procedure-call.ejs +100 -100
  77. package/templates/modular/route-types.ejs +18 -18
  78. package/src/schema-parser/schema-processor.js +0 -79
  79. package/src/schema-parser/schema-routes.js +0 -950
  80. package/src/templates.js +0 -182
  81. package/src/translators/JavaScript.js +0 -60
package/index.js CHANGED
@@ -6,245 +6,296 @@
6
6
  // License text available at https://opensource.org/licenses/MIT
7
7
  // Repository https://github.com/acacode/swagger-typescript-api
8
8
 
9
- const _ = require("lodash");
10
- const { version, name } = require("./package.json");
11
- const { cli } = require("./cli");
12
- const { generateApi, generateTemplates } = require("./src");
13
- const { HTTP_CLIENT } = require("./src/constants");
14
- const { resolve } = require("path");
15
- const { CodeGenConfig } = require("./src/configuration");
16
- const { TemplatesGenConfig } = require("./src/commands/generate-templates/configuration");
9
+ const { version, name } = require('./package.json');
10
+ const { cli } = require('./cli');
11
+ const { generateApi, generateTemplates } = require('./src');
12
+ const { HTTP_CLIENT } = require('./src/constants');
13
+ const { resolve } = require('path');
14
+ const { CodeGenConfig } = require('./src/configuration');
15
+ const {
16
+ TemplatesGenConfig,
17
+ } = require('./src/commands/generate-templates/configuration');
17
18
 
18
19
  const codeGenBaseConfig = new CodeGenConfig({});
19
20
  const templateGenBaseConfig = new TemplatesGenConfig({});
20
21
 
21
22
  const program = cli({
22
23
  name: name,
23
- alias: "sta",
24
+ alias: 'sta',
24
25
  version: version,
25
- description: "Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.",
26
+ description:
27
+ 'Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.',
26
28
  options: [
27
29
  {
28
- flags: "-p, --path <string>",
29
- description: "path/url to swagger scheme",
30
+ flags: '-p, --path <string>',
31
+ description: 'path/url to swagger scheme',
30
32
  required: true,
31
33
  },
32
34
  {
33
- flags: "-o, --output <string>",
34
- description: "output path of typescript api file",
35
- default: "./",
35
+ flags: '-o, --output <string>',
36
+ description: 'output path of typescript api file',
37
+ default: './',
36
38
  },
37
39
  {
38
- flags: "-n, --name <string>",
39
- description: "name of output typescript api file",
40
+ flags: '-n, --name <string>',
41
+ description: 'name of output typescript api file',
40
42
  default: codeGenBaseConfig.fileName,
41
43
  },
42
44
  {
43
- flags: "-t, --templates <string>",
44
- description: "path to folder containing templates",
45
+ flags: '-t, --templates <string>',
46
+ description: 'path to folder containing templates',
45
47
  },
46
48
  {
47
- flags: "-d, --default-as-success",
49
+ flags: '-d, --default-as-success',
48
50
  description:
49
51
  'use "default" response status code as success response too.\n' +
50
52
  'some swagger schemas use "default" response status code as success response type by default.',
51
53
  default: codeGenBaseConfig.defaultResponseAsSuccess,
54
+ internal: { name: 'defaultResponseAsSuccess' },
52
55
  },
53
56
  {
54
- flags: "-r, --responses",
55
- description: "generate additional information about request responses\n" + "also add typings for bad responses",
57
+ flags: '-r, --responses',
58
+ description:
59
+ 'generate additional information about request responses\n' +
60
+ 'also add typings for bad responses',
56
61
  default: codeGenBaseConfig.generateResponses,
62
+ internal: { name: 'generateResponses' },
57
63
  },
58
64
  {
59
- flags: "--union-enums",
65
+ flags: '--union-enums',
60
66
  description: 'generate all "enum" types as union types (T1 | T2 | TN)',
61
67
  default: codeGenBaseConfig.generateUnionEnums,
68
+ internal: { name: 'generateUnionEnums' },
62
69
  },
63
70
  {
64
- flags: "--add-readonly",
65
- description: "generate readonly properties",
71
+ flags: '--add-readonly',
72
+ description: 'generate readonly properties',
66
73
  default: codeGenBaseConfig.addReadonly,
67
74
  },
68
75
  {
69
- flags: "--route-types",
70
- description: "generate type definitions for API routes",
76
+ flags: '--route-types',
77
+ description: 'generate type definitions for API routes',
71
78
  default: codeGenBaseConfig.generateRouteTypes,
79
+ internal: { name: 'generateRouteTypes' },
72
80
  },
73
81
  {
74
- flags: "--no-client",
75
- description: "do not generate an API class",
82
+ flags: '--no-client',
83
+ description: 'do not generate an API class',
76
84
  default: codeGenBaseConfig.generateClient,
77
85
  },
78
86
  {
79
- flags: "--enum-names-as-values",
80
- description: "use values in 'x-enumNames' as enum values (not only as keys)",
87
+ flags: '--enum-names-as-values',
88
+ description:
89
+ "use values in 'x-enumNames' as enum values (not only as keys)",
81
90
  default: codeGenBaseConfig.enumNamesAsValues,
82
91
  },
83
92
  {
84
- flags: "--extract-request-params",
93
+ flags: '--extract-request-params',
85
94
  description:
86
- "extract request params to data contract (Also combine path params and query params into one object)",
95
+ 'extract request params to data contract (Also combine path params and query params into one object)',
87
96
  default: codeGenBaseConfig.extractRequestParams,
97
+ internal: { formatter: Boolean },
88
98
  },
89
99
  {
90
- flags: "--extract-request-body",
91
- description: "extract request body type to data contract",
100
+ flags: '--extract-request-body',
101
+ description: 'extract request body type to data contract',
92
102
  default: codeGenBaseConfig.extractRequestBody,
103
+ internal: { formatter: Boolean },
93
104
  },
94
105
  {
95
- flags: "--extract-response-body",
96
- description: "extract response body type to data contract",
106
+ flags: '--extract-response-body',
107
+ description: 'extract response body type to data contract',
97
108
  default: codeGenBaseConfig.extractResponseBody,
109
+ internal: { formatter: Boolean },
98
110
  },
99
111
  {
100
- flags: "--extract-response-error",
101
- description: "extract response error type to data contract",
112
+ flags: '--extract-response-error',
113
+ description: 'extract response error type to data contract',
102
114
  default: codeGenBaseConfig.extractResponseError,
115
+ internal: { formatter: Boolean },
103
116
  },
104
117
  {
105
- flags: "--modular",
106
- description: "generate separated files for http client, data contracts, and routes",
118
+ flags: '--extract-responses',
119
+ description: 'extract all responses described in /components/responses',
120
+ default: codeGenBaseConfig.extractResponses,
121
+ internal: { formatter: Boolean },
122
+ },
123
+ {
124
+ flags: '--modular',
125
+ description:
126
+ 'generate separated files for http client, data contracts, and routes',
107
127
  default: codeGenBaseConfig.modular,
128
+ internal: { formatter: Boolean },
108
129
  },
109
130
  {
110
- flags: "--js",
111
- description: "generate js api module with declaration file",
131
+ flags: '--js',
132
+ description: 'generate js api module with declaration file',
112
133
  default: codeGenBaseConfig.toJS,
134
+ internal: { formatter: Boolean, name: 'toJS' },
113
135
  },
114
136
  {
115
- flags: "--module-name-index <number>",
137
+ flags: '--module-name-index <number>',
116
138
  description:
117
- "determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)",
139
+ 'determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)',
118
140
  default: codeGenBaseConfig.moduleNameIndex,
141
+ internal: { formatter: (moduleNameIndex) => +moduleNameIndex || 0 },
119
142
  },
120
143
  {
121
- flags: "--module-name-first-tag",
122
- description: "splits routes based on the first tag",
144
+ flags: '--module-name-first-tag',
145
+ description: 'splits routes based on the first tag',
123
146
  default: codeGenBaseConfig.moduleNameFirstTag,
124
147
  },
125
148
  {
126
- flags: "--disableStrictSSL",
127
- description: "disabled strict SSL",
149
+ flags: '--disableStrictSSL',
150
+ description: 'disabled strict SSL',
128
151
  default: codeGenBaseConfig.disableStrictSSL,
152
+ internal: { formatter: Boolean },
129
153
  },
130
154
  {
131
- flags: "--disableProxy",
132
- description: "disabled proxy",
155
+ flags: '--disableProxy',
156
+ description: 'disabled proxy',
133
157
  default: codeGenBaseConfig.disableProxy,
158
+ internal: { formatter: Boolean },
134
159
  },
135
160
  {
136
- flags: "--axios",
137
- description: "generate axios http client",
138
- default: codeGenBaseConfig.httpClientType === "axios",
161
+ flags: '--axios',
162
+ description: 'generate axios http client',
163
+ default: codeGenBaseConfig.httpClientType === HTTP_CLIENT.AXIOS,
139
164
  },
140
165
  {
141
- flags: "--unwrap-response-data",
142
- description: "unwrap the data item from the response",
166
+ flags: '--unwrap-response-data',
167
+ description: 'unwrap the data item from the response',
143
168
  default: codeGenBaseConfig.unwrapResponseData,
144
169
  },
145
170
  {
146
- flags: "--disable-throw-on-error",
147
- description: "Do not throw an error when response.ok is not true",
171
+ flags: '--disable-throw-on-error',
172
+ description: 'Do not throw an error when response.ok is not true',
148
173
  default: codeGenBaseConfig.disableThrowOnError,
149
174
  },
150
175
  {
151
- flags: "--single-http-client",
152
- description: "Ability to send HttpClient instance to Api constructor",
176
+ flags: '--single-http-client',
177
+ description: 'Ability to send HttpClient instance to Api constructor',
153
178
  default: codeGenBaseConfig.singleHttpClient,
179
+ internal: { formatter: Boolean },
154
180
  },
155
181
  {
156
- flags: "--silent",
157
- description: "Output only errors to console",
182
+ flags: '--silent',
183
+ description: 'Output only errors to console',
158
184
  default: codeGenBaseConfig.silent,
185
+ internal: { formatter: Boolean },
159
186
  },
160
187
  {
161
- flags: "--default-response <type>",
162
- description: "default type for empty response schema",
188
+ flags: '--default-response <type>',
189
+ description: 'default type for empty response schema',
163
190
  default: codeGenBaseConfig.defaultResponseType,
191
+ internal: { name: 'defaultResponseType' },
164
192
  },
165
193
  {
166
- flags: "--type-prefix <string>",
167
- description: "data contract name prefix",
194
+ flags: '--type-prefix <string>',
195
+ description: 'data contract name prefix',
168
196
  default: codeGenBaseConfig.typePrefix,
169
197
  },
170
198
  {
171
- flags: "--type-suffix <string>",
172
- description: "data contract name suffix",
199
+ flags: '--type-suffix <string>',
200
+ description: 'data contract name suffix',
173
201
  default: codeGenBaseConfig.typeSuffix,
174
202
  },
175
203
  {
176
- flags: "--clean-output",
177
- description: "clean output folder before generate api. WARNING: May cause data loss",
204
+ flags: '--clean-output',
205
+ description:
206
+ 'clean output folder before generate api. WARNING: May cause data loss',
178
207
  default: codeGenBaseConfig.cleanOutput,
208
+ internal: { formatter: Boolean },
179
209
  },
180
210
  {
181
- flags: "--api-class-name <string>",
182
- description: "name of the api class",
211
+ flags: '--api-class-name <string>',
212
+ description: 'name of the api class',
183
213
  default: codeGenBaseConfig.apiClassName,
184
214
  },
185
215
  {
186
- flags: "--patch",
187
- description: "fix up small errors in the swagger source definition",
216
+ flags: '--patch',
217
+ description: 'fix up small errors in the swagger source definition',
188
218
  default: codeGenBaseConfig.patch,
219
+ internal: { formatter: Boolean },
189
220
  },
190
221
  {
191
- flags: "--debug",
192
- description: "additional information about processes inside this tool",
222
+ flags: '--debug',
223
+ description: 'additional information about processes inside this tool',
193
224
  default: codeGenBaseConfig.debug,
194
225
  },
195
226
  {
196
- flags: "--another-array-type",
197
- description: "generate array types as Array<Type> (by default Type[])",
227
+ flags: '--another-array-type',
228
+ description: 'generate array types as Array<Type> (by default Type[])',
198
229
  default: codeGenBaseConfig.anotherArrayType,
199
230
  },
200
231
  {
201
- flags: "--sort-types",
202
- description: "sort fields and types",
232
+ flags: '--sort-types',
233
+ description: 'sort fields and types',
203
234
  default: codeGenBaseConfig.sortTypes,
204
235
  },
205
236
  {
206
- flags: "--extract-enums",
207
- description: "extract all enums from inline interface\\type content to typescript enum construction",
237
+ flags: '--extract-enums',
238
+ description:
239
+ 'extract all enums from inline interface\\type content to typescript enum construction',
208
240
  default: codeGenBaseConfig.extractEnums,
209
241
  },
242
+ {
243
+ flags: '--sort-routes',
244
+ description: 'sort routes in alphabetical order',
245
+ default: codeGenBaseConfig.sortRoutes,
246
+ },
247
+ {
248
+ flags: '--custom-config <string>',
249
+ description: 'custom config: primitiveTypeConstructs, hooks, ... ',
250
+ default: '',
251
+ },
210
252
  ],
211
253
  });
212
254
 
213
255
  program.addCommand({
214
- name: "generate-templates",
256
+ name: 'generate-templates',
215
257
  description: `Generate ".ejs" templates needed for generate api`,
216
258
  options: [
217
259
  {
218
- flags: "-o, --output <string>",
219
- description: "output path of generated templates",
260
+ flags: '-o, --output <string>',
261
+ description: 'output path of generated templates',
220
262
  default: templateGenBaseConfig.output,
221
263
  },
222
264
  {
223
- flags: "-m, --modular",
224
- description: "generate templates needed to separate files for http client, data contracts, and routes",
265
+ flags: '-m, --modular',
266
+ description:
267
+ 'generate templates needed to separate files for http client, data contracts, and routes',
225
268
  default: templateGenBaseConfig.modular,
269
+ internal: { formatter: Boolean },
226
270
  },
227
271
  {
228
- flags: "--http-client <string>",
229
- description: `http client type (possible values: ${Object.values(HTTP_CLIENT)
272
+ flags: '--http-client <string>',
273
+ description: `http client type (possible values: ${Object.values(
274
+ HTTP_CLIENT,
275
+ )
230
276
  .map((v) => `"${v}"`)
231
- .join(", ")})`,
277
+ .join(', ')})`,
232
278
  default: templateGenBaseConfig.httpClientType,
279
+ internal: { name: 'httpClientType' },
233
280
  },
234
281
  {
235
- flags: "-c, --clean-output",
236
- description: "clean output folder before generate template. WARNING: May cause data loss",
282
+ flags: '-c, --clean-output',
283
+ description:
284
+ 'clean output folder before generate template. WARNING: May cause data loss',
237
285
  default: templateGenBaseConfig.cleanOutput,
286
+ internal: { formatter: Boolean },
238
287
  },
239
288
  {
240
- flags: "-r, --rewrite",
241
- description: "rewrite content in existing templates",
289
+ flags: '-r, --rewrite',
290
+ description: 'rewrite content in existing templates',
242
291
  default: templateGenBaseConfig.rewrite,
292
+ internal: { formatter: Boolean },
243
293
  },
244
294
  {
245
- flags: "--silent",
246
- description: "Output only errors to console",
295
+ flags: '--silent',
296
+ description: 'Output only errors to console',
247
297
  default: templateGenBaseConfig.silent,
298
+ internal: { formatter: Boolean },
248
299
  },
249
300
  ],
250
301
  });
@@ -252,58 +303,36 @@ program.addCommand({
252
303
  const main = async () => {
253
304
  const { command, options } = await program.execute({ args: process.argv });
254
305
 
306
+ let customConfig = null;
307
+
308
+ if (options.customConfig) {
309
+ try {
310
+ const customConfigPath = resolve(process.cwd(), options.customConfig);
311
+ console.log(`✨ found custom config at: ${customConfigPath}`);
312
+ customConfig = require(customConfigPath);
313
+ } catch (e) {
314
+ /* empty */
315
+ }
316
+ }
317
+
255
318
  try {
256
319
  switch (command) {
257
320
  case null: {
258
321
  await generateApi({
322
+ ...options,
259
323
  name: options.name,
260
324
  url: options.path,
261
325
  generateRouteTypes: options.routeTypes,
262
326
  generateClient: !!(options.axios || options.client),
263
327
  httpClientType: options.axios ? HTTP_CLIENT.AXIOS : HTTP_CLIENT.FETCH,
264
- defaultResponseAsSuccess: options.defaultAsSuccess,
265
- defaultResponseType: options.defaultResponse,
266
- unwrapResponseData: options.unwrapResponseData,
267
- disableThrowOnError: options.disableThrowOnError,
268
- sortTypes: options.sortTypes,
269
- generateUnionEnums: options.unionEnums,
270
- addReadonly: options.addReadonly,
271
- generateResponses: options.responses,
272
- extractRequestParams: !!options.extractRequestParams,
273
- extractRequestBody: !!options.extractRequestBody,
274
- extractResponseBody: !!options.extractResponseBody,
275
- extractResponseError: !!options.extractResponseError,
276
328
  input: resolve(process.cwd(), options.path),
277
- output: resolve(process.cwd(), options.output || "."),
278
- templates: options.templates,
279
- modular: !!options.modular,
280
- toJS: !!options.js,
281
- enumNamesAsValues: options.enumNamesAsValues,
282
- moduleNameIndex: +(options.moduleNameIndex || 0),
283
- moduleNameFirstTag: options.moduleNameFirstTag,
284
- disableStrictSSL: !!options.disableStrictSSL,
285
- disableProxy: !!options.disableProxy,
286
- singleHttpClient: !!options.singleHttpClient,
287
- cleanOutput: !!options.cleanOutput,
288
- silent: !!options.silent,
289
- typePrefix: options.typePrefix,
290
- typeSuffix: options.typeSuffix,
291
- patch: !!options.patch,
292
- apiClassName: options.apiClassName,
293
- debug: options.debug,
294
- anotherArrayType: options.anotherArrayType,
329
+ output: resolve(process.cwd(), options.output || '.'),
330
+ ...customConfig,
295
331
  });
296
332
  break;
297
333
  }
298
- case "generate-templates": {
299
- await generateTemplates({
300
- cleanOutput: options.cleanOutput,
301
- output: options.output,
302
- httpClientType: options.httpClient,
303
- modular: options.modular,
304
- silent: options.silent,
305
- rewrite: options.rewrite,
306
- });
334
+ case 'generate-templates': {
335
+ await generateTemplates(options);
307
336
  break;
308
337
  }
309
338
  default: {
package/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "13.0.0-experimental-1",
3
+ "version": "13.0.1",
4
4
  "description": "Generate typescript/javascript api from swagger schema",
5
5
  "scripts": {
6
+ "update-deps-to-latest": "npx --yes npm-check-updates && npm i",
7
+ "lint": "eslint .",
8
+ "lint:fix": "eslint . --fix",
6
9
  "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
7
10
  "cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts",
8
11
  "node": "node swagger-test-cli/generate.js",
9
12
  "node:debug": "node --nolazy swagger-test-cli/generate.js",
10
13
  "contributors": "all-contributors generate",
11
14
  "cli:help": "node index.js -h",
12
- "test-all": "node --unhandled-rejections=strict ./scriptsRunner.js generate validate test:*",
13
- "test-all(update-snapshots)": "cross-env UPDATE_SNAPSHOTS=true node --unhandled-rejections=strict ./scriptsRunner.js generate validate test:*",
14
- "test-all-extended": "node --unhandled-rejections=strict ./scriptsRunner.js generate-extended validate generate validate test:*",
15
- "test-specific": "node ./scriptsRunner.js generate validate test:*",
16
- "test-specific-only": "node ./scriptsRunner.js test:*",
15
+ "test-all": "npm run test-extended && npm run test-simple && npm run test-specific",
16
+ "test-all(update-snapshots)": "cross-env UPDATE_SNAPSHOTS=true npm run test-all",
17
+ "test-simple": "node --unhandled-rejections=strict scripts_runner.js generate validate",
18
+ "test-extended": "node --unhandled-rejections=strict scripts_runner.js generate-extended validate",
19
+ "test-specific": "node --unhandled-rejections=strict scripts_runner.js test:*",
20
+ "test-specific(update-snapshots)": "cross-env UPDATE_SNAPSHOTS=true node --unhandled-rejections=strict scripts_runner.js test:*",
17
21
  "generate": "node tests/generate.js",
18
22
  "generate-extended": "node tests/generate-extended.js",
19
- "generate:debug": "node --nolazy tests/generate.js",
20
23
  "validate": "node tests/validate.js",
21
24
  "validate:debug": "node --nolazy tests/validate.js",
22
25
  "test:--route-types": "node tests/spec/routeTypes/test.js",
@@ -37,6 +40,7 @@
37
40
  "test:--extract-response-error": "node tests/spec/extractResponseError/test.js",
38
41
  "test:--enum-names-as-values": "node tests/spec/enumNamesAsValues/test.js",
39
42
  "test:--default-response": "node tests/spec/defaultResponse/test.js",
43
+ "test:const-keyword": "node tests/spec/const-keyword/test.js",
40
44
  "test:--js": "node tests/spec/js/test.js",
41
45
  "test:jsSingleHttpClientModular": "node tests/spec/jsSingleHttpClientModular/test.js",
42
46
  "test:--js--axios": "node tests/spec/jsAxios/test.js",
@@ -47,7 +51,7 @@
47
51
  "test:--type-suffix--type-prefix": "node tests/spec/typeSuffixPrefix/test.js",
48
52
  "test:--dot-path-params": "node tests/spec/dot-path-params/test.js",
49
53
  "test:--primitive-type-constructs": "node tests/spec/primitive-type-constructs/test.js",
50
- "test:--cli": "node index.js -p tests/spec/cli/schema.json -o tests/spec/cli -n schema.ts --extract-response-body --extract-response-error --api-class-name MySuperApi --type-prefix Prefix && node tests/spec/cli/test.js",
54
+ "test:--cli": "rimraf tests/spec/cli/schema.ts && node index.js -p tests/spec/cli/schema.json -o tests/spec/cli -n schema.ts --extract-response-body --extract-response-error --api-class-name MySuperApi --type-prefix Prefix && node tests/spec/cli/test.js",
51
55
  "test:partialBaseTemplate": "node tests/spec/partialBaseTemplate/test.js",
52
56
  "test:partialDefaultTemplate": "node tests/spec/partialDefaultTemplate/test.js",
53
57
  "test:--patch": "node tests/spec/patch/test.js",
@@ -59,49 +63,51 @@
59
63
  "test:another-query-params": "node tests/spec/another-query-params/test.js",
60
64
  "test:on-insert-path-param": "node tests/spec/on-insert-path-param/test.js",
61
65
  "test:extra-templates": "node tests/spec/extra-templates/test.js",
62
- "test:extract-enums": "node tests/spec/extract-enums/test.js"
66
+ "test:extract-enums": "node tests/spec/extract-enums/test.js",
67
+ "test:discriminator": "node tests/spec/discriminator/test.js",
68
+ "test:sort-types": "node tests/spec/sortTypes/test.js",
69
+ "test:sort-types-false": "node tests/spec/sortTypes-false/test.js"
63
70
  },
64
71
  "author": "acacode",
65
72
  "license": "MIT",
66
73
  "typings": "./index.d.ts",
67
74
  "main": "src/index.js",
68
75
  "devDependencies": {
69
- "@types/lodash": "^4.14.186",
70
- "@types/node": "^18.11.7",
71
- "@types/prettier": "^2.7.1",
72
- "all-contributors-cli": "^6.20.0",
73
- "axios": "^1.1.3",
76
+ "eslint": "^8.44.0",
77
+ "eslint-config-prettier": "^8.8.0",
78
+ "eslint-plugin-prettier": "^5.0.0",
79
+ "@types/lodash": "^4.14.195",
80
+ "@types/node": "^20.4.1",
81
+ "@types/prettier": "^2.7.3",
82
+ "all-contributors-cli": "^6.26.1",
83
+ "axios": "^1.4.0",
74
84
  "cross-env": "^7.0.3",
85
+ "dotenv": "^16.3.1",
75
86
  "git-diff": "^2.0.6",
76
- "husky": "^4.3.6",
77
- "pretty-quick": "^3.1.0"
87
+ "husky": "^8.0.3",
88
+ "pretty-quick": "^3.1.3",
89
+ "rimraf": "^5.0.1"
78
90
  },
79
91
  "dependencies": {
80
92
  "@types/swagger-schema-official": "2.0.22",
81
- "cosmiconfig": "7.0.1",
93
+ "cosmiconfig": "8.2.0",
82
94
  "didyoumean": "^1.2.2",
83
- "eta": "1.12.3",
95
+ "eta": "^2.2.0",
84
96
  "js-yaml": "4.1.0",
85
97
  "lodash": "4.17.21",
86
- "make-dir": "3.1.0",
87
- "nanoid": "3.3.4",
88
- "node-emoji": "1.11.0",
89
- "node-fetch": "^3.2.10",
90
- "prettier": "2.7.1",
98
+ "make-dir": "4.0.0",
99
+ "nanoid": "3.3.6",
100
+ "node-emoji": "2.1.0",
101
+ "node-fetch": "^3.3.1",
102
+ "prettier": "3.0.0",
91
103
  "swagger-schema-official": "2.0.0-bab6bed",
92
104
  "swagger2openapi": "7.0.8",
93
- "typescript": "4.8.4"
105
+ "typescript": "5.1.6"
94
106
  },
95
107
  "bin": {
96
108
  "swagger-typescript-api": "index.js",
97
109
  "sta": "index.js"
98
110
  },
99
- "husky": {
100
- "hooks": {
101
- "pre-commit": "pretty-quick --staged",
102
- "post-commit": "git update-index -g"
103
- }
104
- },
105
111
  "keywords": [
106
112
  "openapi",
107
113
  "swagger",