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

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 +22 -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 +158 -135
  12. package/package.json +35 -30
  13. package/src/code-formatter.js +28 -13
  14. package/src/code-gen-process.js +357 -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 +167 -95
  20. package/src/constants.js +28 -22
  21. package/src/index.js +3 -4
  22. package/src/schema-components-map.js +39 -23
  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 +301 -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 +34 -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 +208 -427
  37. package/src/schema-parser/schema-utils.js +123 -58
  38. package/src/schema-parser/util/enum-key-resolver.js +26 -0
  39. package/src/schema-routes/schema-routes.js +1225 -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 +33 -18
  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,290 @@
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: '--modular',
119
+ description:
120
+ 'generate separated files for http client, data contracts, and routes',
107
121
  default: codeGenBaseConfig.modular,
122
+ internal: { formatter: Boolean },
108
123
  },
109
124
  {
110
- flags: "--js",
111
- description: "generate js api module with declaration file",
125
+ flags: '--js',
126
+ description: 'generate js api module with declaration file',
112
127
  default: codeGenBaseConfig.toJS,
128
+ internal: { formatter: Boolean, name: 'toJS' },
113
129
  },
114
130
  {
115
- flags: "--module-name-index <number>",
131
+ flags: '--module-name-index <number>',
116
132
  description:
117
- "determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)",
133
+ 'determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)',
118
134
  default: codeGenBaseConfig.moduleNameIndex,
135
+ internal: { formatter: (moduleNameIndex) => +moduleNameIndex || 0 },
119
136
  },
120
137
  {
121
- flags: "--module-name-first-tag",
122
- description: "splits routes based on the first tag",
138
+ flags: '--module-name-first-tag',
139
+ description: 'splits routes based on the first tag',
123
140
  default: codeGenBaseConfig.moduleNameFirstTag,
124
141
  },
125
142
  {
126
- flags: "--disableStrictSSL",
127
- description: "disabled strict SSL",
143
+ flags: '--disableStrictSSL',
144
+ description: 'disabled strict SSL',
128
145
  default: codeGenBaseConfig.disableStrictSSL,
146
+ internal: { formatter: Boolean },
129
147
  },
130
148
  {
131
- flags: "--disableProxy",
132
- description: "disabled proxy",
149
+ flags: '--disableProxy',
150
+ description: 'disabled proxy',
133
151
  default: codeGenBaseConfig.disableProxy,
152
+ internal: { formatter: Boolean },
134
153
  },
135
154
  {
136
- flags: "--axios",
137
- description: "generate axios http client",
138
- default: codeGenBaseConfig.httpClientType === "axios",
155
+ flags: '--axios',
156
+ description: 'generate axios http client',
157
+ default: codeGenBaseConfig.httpClientType === HTTP_CLIENT.AXIOS,
139
158
  },
140
159
  {
141
- flags: "--unwrap-response-data",
142
- description: "unwrap the data item from the response",
160
+ flags: '--unwrap-response-data',
161
+ description: 'unwrap the data item from the response',
143
162
  default: codeGenBaseConfig.unwrapResponseData,
144
163
  },
145
164
  {
146
- flags: "--disable-throw-on-error",
147
- description: "Do not throw an error when response.ok is not true",
165
+ flags: '--disable-throw-on-error',
166
+ description: 'Do not throw an error when response.ok is not true',
148
167
  default: codeGenBaseConfig.disableThrowOnError,
149
168
  },
150
169
  {
151
- flags: "--single-http-client",
152
- description: "Ability to send HttpClient instance to Api constructor",
170
+ flags: '--single-http-client',
171
+ description: 'Ability to send HttpClient instance to Api constructor',
153
172
  default: codeGenBaseConfig.singleHttpClient,
173
+ internal: { formatter: Boolean },
154
174
  },
155
175
  {
156
- flags: "--silent",
157
- description: "Output only errors to console",
176
+ flags: '--silent',
177
+ description: 'Output only errors to console',
158
178
  default: codeGenBaseConfig.silent,
179
+ internal: { formatter: Boolean },
159
180
  },
160
181
  {
161
- flags: "--default-response <type>",
162
- description: "default type for empty response schema",
182
+ flags: '--default-response <type>',
183
+ description: 'default type for empty response schema',
163
184
  default: codeGenBaseConfig.defaultResponseType,
185
+ internal: { name: 'defaultResponseType' },
164
186
  },
165
187
  {
166
- flags: "--type-prefix <string>",
167
- description: "data contract name prefix",
188
+ flags: '--type-prefix <string>',
189
+ description: 'data contract name prefix',
168
190
  default: codeGenBaseConfig.typePrefix,
169
191
  },
170
192
  {
171
- flags: "--type-suffix <string>",
172
- description: "data contract name suffix",
193
+ flags: '--type-suffix <string>',
194
+ description: 'data contract name suffix',
173
195
  default: codeGenBaseConfig.typeSuffix,
174
196
  },
175
197
  {
176
- flags: "--clean-output",
177
- description: "clean output folder before generate api. WARNING: May cause data loss",
198
+ flags: '--clean-output',
199
+ description:
200
+ 'clean output folder before generate api. WARNING: May cause data loss',
178
201
  default: codeGenBaseConfig.cleanOutput,
202
+ internal: { formatter: Boolean },
179
203
  },
180
204
  {
181
- flags: "--api-class-name <string>",
182
- description: "name of the api class",
205
+ flags: '--api-class-name <string>',
206
+ description: 'name of the api class',
183
207
  default: codeGenBaseConfig.apiClassName,
184
208
  },
185
209
  {
186
- flags: "--patch",
187
- description: "fix up small errors in the swagger source definition",
210
+ flags: '--patch',
211
+ description: 'fix up small errors in the swagger source definition',
188
212
  default: codeGenBaseConfig.patch,
213
+ internal: { formatter: Boolean },
189
214
  },
190
215
  {
191
- flags: "--debug",
192
- description: "additional information about processes inside this tool",
216
+ flags: '--debug',
217
+ description: 'additional information about processes inside this tool',
193
218
  default: codeGenBaseConfig.debug,
194
219
  },
195
220
  {
196
- flags: "--another-array-type",
197
- description: "generate array types as Array<Type> (by default Type[])",
221
+ flags: '--another-array-type',
222
+ description: 'generate array types as Array<Type> (by default Type[])',
198
223
  default: codeGenBaseConfig.anotherArrayType,
199
224
  },
200
225
  {
201
- flags: "--sort-types",
202
- description: "sort fields and types",
226
+ flags: '--sort-types',
227
+ description: 'sort fields and types',
203
228
  default: codeGenBaseConfig.sortTypes,
204
229
  },
205
230
  {
206
- flags: "--extract-enums",
207
- description: "extract all enums from inline interface\\type content to typescript enum construction",
231
+ flags: '--extract-enums',
232
+ description:
233
+ 'extract all enums from inline interface\\type content to typescript enum construction',
208
234
  default: codeGenBaseConfig.extractEnums,
209
235
  },
236
+ {
237
+ flags: '--sort-routes',
238
+ description: 'sort routes in alphabetical order',
239
+ default: codeGenBaseConfig.sortRoutes,
240
+ },
241
+ {
242
+ flags: '--custom-config <string>',
243
+ description: 'custom config: primitiveTypeConstructs, hooks, ... ',
244
+ default: '',
245
+ },
210
246
  ],
211
247
  });
212
248
 
213
249
  program.addCommand({
214
- name: "generate-templates",
250
+ name: 'generate-templates',
215
251
  description: `Generate ".ejs" templates needed for generate api`,
216
252
  options: [
217
253
  {
218
- flags: "-o, --output <string>",
219
- description: "output path of generated templates",
254
+ flags: '-o, --output <string>',
255
+ description: 'output path of generated templates',
220
256
  default: templateGenBaseConfig.output,
221
257
  },
222
258
  {
223
- flags: "-m, --modular",
224
- description: "generate templates needed to separate files for http client, data contracts, and routes",
259
+ flags: '-m, --modular',
260
+ description:
261
+ 'generate templates needed to separate files for http client, data contracts, and routes',
225
262
  default: templateGenBaseConfig.modular,
263
+ internal: { formatter: Boolean },
226
264
  },
227
265
  {
228
- flags: "--http-client <string>",
229
- description: `http client type (possible values: ${Object.values(HTTP_CLIENT)
266
+ flags: '--http-client <string>',
267
+ description: `http client type (possible values: ${Object.values(
268
+ HTTP_CLIENT,
269
+ )
230
270
  .map((v) => `"${v}"`)
231
- .join(", ")})`,
271
+ .join(', ')})`,
232
272
  default: templateGenBaseConfig.httpClientType,
273
+ internal: { name: 'httpClientType' },
233
274
  },
234
275
  {
235
- flags: "-c, --clean-output",
236
- description: "clean output folder before generate template. WARNING: May cause data loss",
276
+ flags: '-c, --clean-output',
277
+ description:
278
+ 'clean output folder before generate template. WARNING: May cause data loss',
237
279
  default: templateGenBaseConfig.cleanOutput,
280
+ internal: { formatter: Boolean },
238
281
  },
239
282
  {
240
- flags: "-r, --rewrite",
241
- description: "rewrite content in existing templates",
283
+ flags: '-r, --rewrite',
284
+ description: 'rewrite content in existing templates',
242
285
  default: templateGenBaseConfig.rewrite,
286
+ internal: { formatter: Boolean },
243
287
  },
244
288
  {
245
- flags: "--silent",
246
- description: "Output only errors to console",
289
+ flags: '--silent',
290
+ description: 'Output only errors to console',
247
291
  default: templateGenBaseConfig.silent,
292
+ internal: { formatter: Boolean },
248
293
  },
249
294
  ],
250
295
  });
@@ -252,58 +297,36 @@ program.addCommand({
252
297
  const main = async () => {
253
298
  const { command, options } = await program.execute({ args: process.argv });
254
299
 
300
+ let customConfig = null;
301
+
302
+ if (options.customConfig) {
303
+ try {
304
+ const customConfigPath = resolve(process.cwd(), options.customConfig);
305
+ console.log(`✨ found custom config at: ${customConfigPath}`);
306
+ customConfig = require(customConfigPath);
307
+ } catch (e) {
308
+ /* empty */
309
+ }
310
+ }
311
+
255
312
  try {
256
313
  switch (command) {
257
314
  case null: {
258
315
  await generateApi({
316
+ ...options,
259
317
  name: options.name,
260
318
  url: options.path,
261
319
  generateRouteTypes: options.routeTypes,
262
320
  generateClient: !!(options.axios || options.client),
263
321
  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
322
  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,
323
+ output: resolve(process.cwd(), options.output || '.'),
324
+ ...customConfig,
295
325
  });
296
326
  break;
297
327
  }
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
- });
328
+ case 'generate-templates': {
329
+ await generateTemplates(options);
307
330
  break;
308
331
  }
309
332
  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.0",
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",
@@ -47,7 +50,7 @@
47
50
  "test:--type-suffix--type-prefix": "node tests/spec/typeSuffixPrefix/test.js",
48
51
  "test:--dot-path-params": "node tests/spec/dot-path-params/test.js",
49
52
  "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",
53
+ "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
54
  "test:partialBaseTemplate": "node tests/spec/partialBaseTemplate/test.js",
52
55
  "test:partialDefaultTemplate": "node tests/spec/partialDefaultTemplate/test.js",
53
56
  "test:--patch": "node tests/spec/patch/test.js",
@@ -59,49 +62,51 @@
59
62
  "test:another-query-params": "node tests/spec/another-query-params/test.js",
60
63
  "test:on-insert-path-param": "node tests/spec/on-insert-path-param/test.js",
61
64
  "test:extra-templates": "node tests/spec/extra-templates/test.js",
62
- "test:extract-enums": "node tests/spec/extract-enums/test.js"
65
+ "test:extract-enums": "node tests/spec/extract-enums/test.js",
66
+ "test:discriminator": "node tests/spec/discriminator/test.js",
67
+ "test:sort-types": "node tests/spec/sortTypes/test.js",
68
+ "test:sort-types-false": "node tests/spec/sortTypes-false/test.js"
63
69
  },
64
70
  "author": "acacode",
65
71
  "license": "MIT",
66
72
  "typings": "./index.d.ts",
67
73
  "main": "src/index.js",
68
74
  "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",
75
+ "eslint": "^8.44.0",
76
+ "eslint-config-prettier": "^8.8.0",
77
+ "eslint-plugin-prettier": "^5.0.0",
78
+ "@types/lodash": "^4.14.195",
79
+ "@types/node": "^20.4.1",
80
+ "@types/prettier": "^2.7.3",
81
+ "all-contributors-cli": "^6.26.1",
82
+ "axios": "^1.4.0",
74
83
  "cross-env": "^7.0.3",
84
+ "dotenv": "^16.3.1",
75
85
  "git-diff": "^2.0.6",
76
- "husky": "^4.3.6",
77
- "pretty-quick": "^3.1.0"
86
+ "husky": "^8.0.3",
87
+ "pretty-quick": "^3.1.3",
88
+ "rimraf": "^5.0.1"
78
89
  },
79
90
  "dependencies": {
80
91
  "@types/swagger-schema-official": "2.0.22",
81
- "cosmiconfig": "7.0.1",
92
+ "cosmiconfig": "8.2.0",
82
93
  "didyoumean": "^1.2.2",
83
- "eta": "1.12.3",
94
+ "eta": "^2.2.0",
84
95
  "js-yaml": "4.1.0",
85
96
  "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",
97
+ "make-dir": "4.0.0",
98
+ "nanoid": "3.3.6",
99
+ "node-emoji": "2.1.0",
100
+ "node-fetch": "^3.3.1",
101
+ "prettier": "3.0.0",
91
102
  "swagger-schema-official": "2.0.0-bab6bed",
92
103
  "swagger2openapi": "7.0.8",
93
- "typescript": "4.8.4"
104
+ "typescript": "5.1.6"
94
105
  },
95
106
  "bin": {
96
107
  "swagger-typescript-api": "index.js",
97
108
  "sta": "index.js"
98
109
  },
99
- "husky": {
100
- "hooks": {
101
- "pre-commit": "pretty-quick --staged",
102
- "post-commit": "git update-index -g"
103
- }
104
- },
105
110
  "keywords": [
106
111
  "openapi",
107
112
  "swagger",