swagger-typescript-api 13.0.27 → 13.1.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.
package/CHANGELOG.md CHANGED
@@ -1,18 +1,44 @@
1
1
  # swagger-typescript-api
2
2
 
3
+ ## 13.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1144](https://github.com/acacode/swagger-typescript-api/pull/1144) [`ea1df18`](https://github.com/acacode/swagger-typescript-api/commit/ea1df18aebec54109972f22e32199a5aeacf7c7f) Thanks [@smorimoto](https://github.com/smorimoto)! - Use `c12` for wider configuration file format support.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1171](https://github.com/acacode/swagger-typescript-api/pull/1171) [`c1cc45a`](https://github.com/acacode/swagger-typescript-api/commit/c1cc45a6f27698f2b21cc35696cf529b0e9a210d) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix TypeScript declaration file path.
12
+
13
+ - [#1145](https://github.com/acacode/swagger-typescript-api/pull/1145) [`73f6bfd`](https://github.com/acacode/swagger-typescript-api/commit/73f6bfddb501211a30f9dca0e1098f905761badb) Thanks [@smorimoto](https://github.com/smorimoto)! - Replace Prettier with Biome as the code formatter to improve performance during the code generation phase.
14
+
15
+ - [#1141](https://github.com/acacode/swagger-typescript-api/pull/1141) [`821bfad`](https://github.com/acacode/swagger-typescript-api/commit/821bfad0dc8dffc7a8571a052b38f96c3d1c8087) Thanks [@dding-g](https://github.com/dding-g)! - Remove redundant `union-enums` option in favor of `generate-union-enums`.
16
+
17
+ ## 13.0.28
18
+
19
+ ### Patch Changes
20
+
21
+ - [`6851bdc`](https://github.com/acacode/swagger-typescript-api/commit/6851bdcafa83a80a2be09ea3d95b2ec45b81d24a) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix description for `client` option in `generateCommand`.
22
+
23
+ - [#1121](https://github.com/acacode/swagger-typescript-api/pull/1121) [`5eadf67`](https://github.com/acacode/swagger-typescript-api/commit/5eadf67b038ef16f0489c6c7b614f3fdc57f1498) Thanks [@takayukioda](https://github.com/takayukioda)! - Fix to not use `no-` prefix in options.
24
+
25
+ - [`edca5de`](https://github.com/acacode/swagger-typescript-api/commit/edca5ded764b0fa4356ac49389f5d71b6784352d) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix option name for `generateUnionEnums` in `generateCommand`.
26
+
27
+ - [`9fa8f41`](https://github.com/acacode/swagger-typescript-api/commit/9fa8f4113c8c24070da79cf2d3242ba433ca94d3) Thanks [@smorimoto](https://github.com/smorimoto)! - Sort the CLI arguments alphabetically.
28
+
3
29
  ## 13.0.27
4
30
 
5
31
  ### Patch Changes
6
32
 
7
- - [#1113](https://github.com/acacode/swagger-typescript-api/pull/1113) [`bdb3277`](https://github.com/acacode/swagger-typescript-api/commit/bdb3277302e566bbe182bd13c3ff22f07bd14aa6) Thanks [@smorimoto](https://github.com/smorimoto)! - Add `shims` option in tsup configuration and update `rootDir` path in templates generation process.
33
+ - [#1119](https://github.com/acacode/swagger-typescript-api/pull/1119) [`c5e8d45`](https://github.com/acacode/swagger-typescript-api/commit/c5e8d45d08edad509c23b3f66c2a6c0ffed570a2) Thanks [@smorimoto](https://github.com/smorimoto)! - Add `shims` option in tsup configuration and update `rootDir` path in templates generation process.
8
34
 
9
- - [#1051](https://github.com/acacode/swagger-typescript-api/pull/1051) [`1fe8e24`](https://github.com/acacode/swagger-typescript-api/commit/1fe8e249993642a3fe5cc8da47ef4288421f9774) Thanks [@yepninja](https://github.com/yepninja)! - Resolve internal references in Swagger v2 to OpenAPI v3 conversion by adding `resolveInternal` option and enhancing type definitions for request payloads.
35
+ - [#1119](https://github.com/acacode/swagger-typescript-api/pull/1119) [`c5e8d45`](https://github.com/acacode/swagger-typescript-api/commit/c5e8d45d08edad509c23b3f66c2a6c0ffed570a2) Thanks [@smorimoto](https://github.com/smorimoto)! - Resolve internal references in Swagger v2 to OpenAPI v3 conversion by adding `resolveInternal` option and enhancing type definitions for request payloads.
10
36
 
11
- - [#1118](https://github.com/acacode/swagger-typescript-api/pull/1118) [`00f8995`](https://github.com/acacode/swagger-typescript-api/commit/00f8995f621521e2c0b66ca1660cb3d839f81bc8) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix default value for `no-client` option in `generateCommand` to `false`.
37
+ - [#1119](https://github.com/acacode/swagger-typescript-api/pull/1119) [`c5e8d45`](https://github.com/acacode/swagger-typescript-api/commit/c5e8d45d08edad509c23b3f66c2a6c0ffed570a2) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix default value for `no-client` option in `generateCommand` to `false`.
12
38
 
13
- - [#1113](https://github.com/acacode/swagger-typescript-api/pull/1113) [`28d43b4`](https://github.com/acacode/swagger-typescript-api/commit/28d43b49604f6fa00155a4e4ac95322d5ca86713) Thanks [@smorimoto](https://github.com/smorimoto)! - Add `required` property to output path in `generateTemplatesCommand`.
39
+ - [#1119](https://github.com/acacode/swagger-typescript-api/pull/1119) [`c5e8d45`](https://github.com/acacode/swagger-typescript-api/commit/c5e8d45d08edad509c23b3f66c2a6c0ffed570a2) Thanks [@smorimoto](https://github.com/smorimoto)! - Add `required` property to output path in `generateTemplatesCommand`.
14
40
 
15
- - [#1069](https://github.com/acacode/swagger-typescript-api/pull/1069) [`c06af2e`](https://github.com/acacode/swagger-typescript-api/commit/c06af2e3cf9b03aa37e3652d5312975bb1292d28) Thanks [@yangdan8](https://github.com/yangdan8)! - Fix documentation and type definition to align with actual implementation by renaming `name` to `fileName`.
41
+ - [#1119](https://github.com/acacode/swagger-typescript-api/pull/1119) [`c5e8d45`](https://github.com/acacode/swagger-typescript-api/commit/c5e8d45d08edad509c23b3f66c2a6c0ffed570a2) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix documentation and type definition to align with actual implementation by renaming `name` to `fileName`.
16
42
 
17
43
  ## 13.0.26
18
44
 
@@ -49,3 +75,1478 @@
49
75
  - [#701](https://github.com/acacode/swagger-typescript-api/pull/701) [`0a71f2b`](https://github.com/acacode/swagger-typescript-api/commit/0a71f2b381c40433bc86e39c174e448cb9a14572) Thanks [@nicky1038](https://github.com/nicky1038)! - Remove unnecessary camel case conversion for query params
50
76
 
51
77
  - [#1041](https://github.com/acacode/swagger-typescript-api/pull/1041) [`47381de`](https://github.com/acacode/swagger-typescript-api/commit/47381dec5fde08e96d49164997db9592755dc08a) Thanks [@Jerome1337](https://github.com/Jerome1337)! - Add ts-nocheck comment to auto-generated file
78
+
79
+ ## 13.0.23
80
+
81
+ - use import pattern that supports windows external drives by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/983
82
+
83
+ ## 13.0.22
84
+
85
+ - Consola by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/903
86
+
87
+ ## 13.0.21
88
+
89
+ - Fix `e.values(...).some is not a function` by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/884
90
+
91
+ ## 13.0.20
92
+
93
+ - Fix #880 by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/881
94
+
95
+ ## 13.0.19
96
+
97
+ - Use default export for lodash by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/878
98
+
99
+ ## 13.0.18
100
+
101
+ - This was a version bump only, there were no code changes.
102
+
103
+ ## 13.0.17
104
+
105
+ - Fix types by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/872
106
+ - Fix build warnings by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/873
107
+ - Reduce use of lodash by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/874
108
+ - Fix build warnings by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/875
109
+
110
+ ## 13.0.16
111
+
112
+ - Revert "Fix contentFormatter for FormData returning an empty FormData object" by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/863
113
+
114
+ ## 13.0.15
115
+
116
+ - Make types slightly better by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/859
117
+ - Set the build target to Node.js 18 by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/861
118
+
119
+ ## 13.0.14
120
+
121
+ - fix: format option of requests when using extractResponseBody by @TaopaiC in https://github.com/acacode/swagger-typescript-api/pull/742
122
+ - Fix #671 - Content-Type: "multipart/form-data" is ignored (when using axios) by @cf-dlangston in https://github.com/acacode/swagger-typescript-api/pull/831
123
+
124
+ ## 13.0.13
125
+
126
+ - Fix types by @raing3 in https://github.com/acacode/swagger-typescript-api/pull/825
127
+ - Custom config: handle default export by @shrpne in https://github.com/acacode/swagger-typescript-api/pull/828
128
+
129
+ ## 13.0.12
130
+
131
+ - Fix types by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/812
132
+
133
+ ## 13.0.11
134
+
135
+ - Fix contentFormatter for FormData returning an empty FormData object by @JorensM in https://github.com/acacode/swagger-typescript-api/pull/747
136
+ - Checking if instanceof FormData before creating one by @dolevl in https://github.com/acacode/swagger-typescript-api/pull/680
137
+ - feat: add security in raw route info by @xfoxfu in https://github.com/acacode/swagger-typescript-api/pull/602
138
+ - Get rid of `require` by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/807
139
+
140
+ ## 13.0.10
141
+
142
+ - Add support for both ESM and CJS by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/803
143
+
144
+ ## 13.0.9
145
+
146
+ - ESM by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/788
147
+
148
+ ## 13.0.8
149
+
150
+ - Fix type errors by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/787
151
+
152
+ ## 13.0.7
153
+
154
+ - fix: support shared prettier config files by @pebo in https://github.com/acacode/swagger-typescript-api/pull/781
155
+
156
+ ## 13.0.6
157
+
158
+ - Relax version constraints on dependencies by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/773
159
+ - Keep some dependency constraints tight by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/774
160
+
161
+ ## 13.0.5
162
+
163
+ - This was a version bump only, there were no code changes.
164
+
165
+ ## 13.0.4
166
+
167
+ - add missing apiClassName to GenerateApiParamsBase by @Mearman in https://github.com/acacode/swagger-typescript-api/pull/635
168
+ - fix: fix options manipulation by @vgprst in https://github.com/acacode/swagger-typescript-api/pull/631
169
+ - Fix typos by @szepeviktor in https://github.com/acacode/swagger-typescript-api/pull/698
170
+ - The default branch has been renamed and the next branch has been deprecated by @smorimoto in https://github.com/acacode/swagger-typescript-api/pull/735
171
+ - Clone the response in fetch HTTP client by @depsimon in https://github.com/acacode/swagger-typescript-api/pull/670
172
+
173
+ ## 13.0.3
174
+
175
+ fix: problem with type `any` as base type of discriminator schema (cases when schema without discriminator is empty)
176
+
177
+ ## 13.0.2
178
+
179
+ fix: problem with incorrect settings type suffix for internal discriminator mappings
180
+
181
+ ## 13.0.1
182
+
183
+ feat: `const` keyword OpenAPI 3.0 draft
184
+ fix: problem with using `anyOf`
185
+ feat: `--extract-responses` (nodejs: `extractResponses`) option to extract all schemas from `/components/responses`
186
+ fix: discriminator and mapping with invalid discriminator property name (#551)
187
+ fix: problem with incorrect resolving type name of discriminator mapping types data contracts
188
+
189
+ ## 13.0.0
190
+
191
+ BREAKING_CHANGE: disable support NodeJS 14.x
192
+ BREAKING_CHANGE: change swagger-typescript-api NodeJS "generateApi" function return type
193
+ BREAKING_CHANGE: remove `rawModelTypes` from output api configuration
194
+ feat: `--custom-config <string>` option (#503)
195
+ feat: `--sort-routes` option, ability to sort routes;
196
+ fix: critical bugs based with extract types and enums
197
+ fix: sort types option (sort was not correctly work with nested or extracted types)
198
+ fix: problems based with extracting enums;
199
+ fix: nullable enum with integer values (#543)
200
+ fix: generation enum numbers as strings one (#534)
201
+ chore: refactoring the axios imports
202
+ fix: non-object custom spec extensions (#500)
203
+ fix(docs): input instead of output in readme
204
+ internal: remove redundant internal scripts
205
+ internal: change process with using custom templates
206
+
207
+ ```diff
208
+ interface GenerateApiOutput {
209
+ ...
210
+ - files: { name: string; content: string; declaration: { name: string; content: string } | null }[];
211
+ + files: { fileName: string; fileContent: string; fileExtension: string }[];
212
+ ...
213
+ }
214
+ ```
215
+
216
+ internal: refactor schema parser code (preparing it for async code execution)
217
+ fix: problem with filtering primitive in complex types (#459)
218
+ feat: add discriminator property support (#456)
219
+ internal: prepare code + templates for async code execution (next plans)
220
+ fix: problems with dot in query params (hard fix) (#460)
221
+ feature: ability to send custom Ts output code translator to js. Example:
222
+
223
+ ```ts
224
+ const {
225
+ Translator,
226
+ } = require("swagger-typescript-api/src/translators/translator");
227
+ const {
228
+ JavascriptTranslator,
229
+ } = require("swagger-typescript-api/src/translators/javascript");
230
+
231
+ class MyTranslator extends Translator {
232
+ // or use extends JavascriptTranslator
233
+ translate({ fileName, fileExtension, fileContent }) {
234
+ // format ts\js code with using this codeFormatter (prettier + ts import fixer)
235
+ this.codeFormatter.format(fileContent);
236
+ // config of the code gen process
237
+ // logger
238
+ this.config.this.logger.return[
239
+ {
240
+ fileName,
241
+ fileExtension,
242
+ fileContent,
243
+ }
244
+ ];
245
+ }
246
+ }
247
+ ```
248
+
249
+ ## 12.0.4
250
+
251
+ fix: onCreateRoute skip behaviour
252
+ fix: problems with prefixes\suffixes for extracted requests params, enums
253
+
254
+ **Full Changelog**: https://github.com/acacode/swagger-typescript-api/compare/12.0.3...12.0.4
255
+
256
+ ## 12.0.3
257
+
258
+ security: update the `eta` package to address CVE-2022-25967
259
+
260
+ ## 12.0.2
261
+
262
+ fix: missing option `--extract-enums` (#344)
263
+
264
+ ## 12.0.1
265
+
266
+ fix: problem based with http requests and `disableStrictSSL` option (#453)
267
+ docs: update docs for `requestOptions` nodejs option
268
+
269
+ ## 12.0.0
270
+
271
+ new hooks:
272
+
273
+ ```ts
274
+ /** calls before parse\process route path */
275
+ onPreBuildRoutePath: (routePath: string) => string | void;
276
+ /** calls after parse\process route path */
277
+ onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | void;
278
+ /** calls before insert path param name into string path interpolation */
279
+ onInsertPathParam: (paramName: string, index: number, arr: BuildRouteParam[], resultRoute: string) => string | void;
280
+ /** calls before parse any kind of schema */
281
+ onPreParseSchema: (originalSchema: any, typeName: string, schemaType: string) => any;
282
+ ```
283
+
284
+ BREAKING_CHANGE: add ability to custom prefix for autofix invalid enum keys, invalid type names with nodejs options (`fixInvalidTypeNamePrefix: string`, `fixInvalidEnumKeyPrefix: string`)
285
+ BREAKING_CHANGE: by default all component enum schemas (even numeric) extracting as `enum` TS constructions (#344)
286
+ feature: ability to extract all enums from nested types\interfaces to `enum` TS construction using `--extract-enums` option (#344)
287
+ feature: ability to modify route path params before insert them into string (request url, #446, with using hook `onInsertPathParam`)
288
+ feature: (nodejs) ability to add prefix\suffix for type names and enum keys
289
+
290
+ ```ts
291
+ typePrefix?: string;
292
+ typeSuffix?: string;
293
+ enumKeyPrefix?: string;
294
+ enumKeySuffix?: string;
295
+ ```
296
+
297
+ feature: ability to customize resolving process of the extracting type names (`extractingOptions` nodejs option)
298
+
299
+ ```ts
300
+ extractingOptions = {
301
+ // requestBodySuffix: ["Payload", "Body", "Input"],
302
+ // or
303
+ // requestBodyNameResolver: (typeName, reservedNames) => string;
304
+ // requestParamsSuffix: ["Params"],
305
+ // or
306
+ // requestParamsNameResolver: (typeName, reservedNames) => string;
307
+ // responseBodySuffix: ["Data", "Result", "Output"],
308
+ // or
309
+ // responseBodyNameResolver: (typeName, reservedNames) => string;
310
+ // responseErrorSuffix: ["Error", "Fail", "Fails", "ErrorData", "HttpError", "BadResponse"],
311
+ // or
312
+ // responseErrorNameResolver: (typeName, reservedNames) => string;
313
+ };
314
+ ```
315
+
316
+ docs: update docs for `extraTemplates` option
317
+ fix: problem with default name of single api file (Api.ts)
318
+ fix: problem based with tuple types (#445)
319
+ fix: problem with `defaultResponseType` declaration type
320
+
321
+ ## 11.1.3
322
+
323
+ fix: problems with `text/*` content types (axios, fetch http clients) (thanks @JochenDiekenbrock, #312, #443)
324
+ fix: problem with `application/json*` content type (thanks @JochenDiekenbrock, #440, #441)
325
+ fix: different query type parameters declarations (in route name `{?accountStatus,createdT`, #439)
326
+
327
+ ## 11.1.2
328
+
329
+ fix: problems with missing type imports in `.d.ts` files with using option `--js`
330
+ internal: add extra spec tests
331
+ fix: additionalProperties management problem in Swagger 2 (#343)
332
+ fix: hanging cli after execution finished (#436, thanks @Soarc)
333
+
334
+ ## 11.1.1
335
+
336
+ fix: `--api-class-name` option has no default value (#433)
337
+
338
+ ## 11.1.0
339
+
340
+ BREAKING_CHANGE: replace `axios` to `node-fetch`
341
+ feat: ability to send request options for getting swagger schema by url (`requestOptions` property)
342
+
343
+ ## 11.0.2
344
+
345
+ - fix: problems with --http-client option in `generate-templates` command
346
+ - fix: rewrite file content in `generate-templates` command (`--rewrite` flag)
347
+
348
+ ## 11.0.0
349
+
350
+ ### Breaking changes
351
+
352
+ - `data-contract-jsdoc.ejs` file uses new input structure. Please update your local copy.
353
+ - new codebase (class way)
354
+ - ability to change everything in codegen process configuration with using NodeJS Api
355
+ - ability to call `generateApi` function 2 and more times per 1 NodeJS process.
356
+ - new command `generate-templates` to create source templates
357
+
358
+ ### [feature] Ability to generate source templates
359
+
360
+ New command `generate-templates` which allow you to generate source templates which using with option `--templates`
361
+
362
+ ### [feature] Ability to modify internal codegen typescript structs
363
+
364
+ Everything which creates codegen about output typescript code now contains in `Ts` field in [`src/configuration`](src/configuration.js).
365
+ And this thing is available for end user modifications with using NodeJS Cli option `codeGenConstructs`.
366
+ It contains almost all which is not contains in `.eta`\ `.ejs` templates. For example: `Record<string, any>`, `readonly typeField?: value`, etc
367
+
368
+ Structure of `Ts` property
369
+
370
+ ```ts
371
+ const Ts = {
372
+ Keyword: {
373
+ Number: "number",
374
+ String: "string",
375
+ Boolean: "boolean",
376
+ Any: "any",
377
+ Void: "void",
378
+ Unknown: "unknown",
379
+ Null: "null",
380
+ Undefined: "undefined",
381
+ Object: "object",
382
+ File: "File",
383
+ Date: "Date",
384
+ Type: "type",
385
+ Enum: "enum",
386
+ Interface: "interface",
387
+ Array: "Array",
388
+ Record: "Record",
389
+ Intersection: "&",
390
+ Union: "|",
391
+ },
392
+ CodeGenKeyword: {
393
+ UtilRequiredKeys: "UtilRequiredKeys",
394
+ },
395
+ /**
396
+ * $A[] or Array<$A>
397
+ */
398
+ ArrayType: (content) => {
399
+ if (this.anotherArrayType) {
400
+ return Ts.TypeWithGeneric(Ts.Keyword.Array, [content]);
401
+ }
402
+
403
+ return `${Ts.ExpressionGroup(content)}[]`;
404
+ },
405
+ /**
406
+ * "$A"
407
+ */
408
+ StringValue: (content) => `"${content}"`,
409
+ /**
410
+ * $A
411
+ */
412
+ BooleanValue: (content) => `${content}`,
413
+ /**
414
+ * $A
415
+ */
416
+ NumberValue: (content) => `${content}`,
417
+ /**
418
+ * $A
419
+ */
420
+ NullValue: (content) => content,
421
+ /**
422
+ * $A1 | $A2
423
+ */
424
+ UnionType: (contents) => _.join(_.uniq(contents), ` ${Ts.Keyword.Union} `),
425
+ /**
426
+ * ($A1)
427
+ */
428
+ ExpressionGroup: (content) => (content ? `(${content})` : ""),
429
+ /**
430
+ * $A1 & $A2
431
+ */
432
+ IntersectionType: (contents) =>
433
+ _.join(_.uniq(contents), ` ${Ts.Keyword.Intersection} `),
434
+ /**
435
+ * Record<$A1, $A2>
436
+ */
437
+ RecordType: (key, value) =>
438
+ Ts.TypeWithGeneric(Ts.Keyword.Record, [key, value]),
439
+ /**
440
+ * readonly $key?:$value
441
+ */
442
+ TypeField: ({ readonly, key, optional, value }) =>
443
+ _.compact([
444
+ readonly && "readonly ",
445
+ key,
446
+ optional && "?",
447
+ ": ",
448
+ value,
449
+ ]).join(""),
450
+ /**
451
+ * [key: $A1]: $A2
452
+ */
453
+ InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
454
+ /**
455
+ * $A1 = $A2
456
+ */
457
+ EnumField: (key, value) => `${key} = ${value}`,
458
+ /**
459
+ * $A0.key = $A0.value,
460
+ * $A1.key = $A1.value,
461
+ * $AN.key = $AN.value,
462
+ */
463
+ EnumFieldsWrapper: (contents) =>
464
+ _.map(contents, ({ key, value }) => ` ${Ts.EnumField(key, value)}`).join(
465
+ ",\n"
466
+ ),
467
+ /**
468
+ * {\n $A \n}
469
+ */
470
+ ObjectWrapper: (content) => `{\n${content}\n}`,
471
+ /**
472
+ * /** $A *\/
473
+ */
474
+ MultilineComment: (contents, formatFn) =>
475
+ [
476
+ ...(contents.length === 1
477
+ ? [`/** ${contents[0]} */`]
478
+ : ["/**", ...contents.map((content) => ` * ${content}`), " */"]),
479
+ ].map((part) => `${formatFn ? formatFn(part) : part}\n`),
480
+ /**
481
+ * $A1<...$A2.join(,)>
482
+ */
483
+ TypeWithGeneric: (typeName, genericArgs) => {
484
+ return `${typeName}${
485
+ genericArgs.length ? `<${genericArgs.join(",")}>` : ""
486
+ }`;
487
+ },
488
+ };
489
+ ```
490
+
491
+ ### [feature] Ability to modify swagger schema type/format to typescript construction translators
492
+
493
+ Swagger schema has constructions like `{ "type": "string" | "integer" | etc, "format": "date-time" | "float" | "etc" }` where field `type` is not "readable" for TypeScript.
494
+ And because of this `swagger-typescript-api` has key value group to translate swagger schema fields `type`/`format` to TypeScript constructions.
495
+ See more about [swagger schema type/format data here](https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times)
496
+ For example, current version of default configuration translates this schema
497
+
498
+ ```json
499
+ {
500
+ "type": "string",
501
+ "format": "date-time"
502
+ }
503
+ ```
504
+
505
+ translates to
506
+
507
+ ```ts
508
+ string;
509
+ ```
510
+
511
+ If you need to see `Date` instead of `string` you are able to change it with using `primitiveTypeConstructs`
512
+
513
+ ```ts
514
+ generateApiForTest({
515
+ // ...
516
+ primitiveTypeConstructs: (construct) => ({
517
+ string: {
518
+ "date-time": "Date",
519
+ },
520
+ }),
521
+ });
522
+ ```
523
+
524
+ Structure of `primitiveTypes` property
525
+
526
+ ```ts
527
+ const primitiveTypes = {
528
+ integer: () => Ts.Keyword.Number,
529
+ number: () => Ts.Keyword.Number,
530
+ boolean: () => Ts.Keyword.Boolean,
531
+ object: () => Ts.Keyword.Object,
532
+ file: () => Ts.Keyword.File,
533
+ string: {
534
+ $default: () => Ts.Keyword.String,
535
+
536
+ /** formats */
537
+ binary: () => Ts.Keyword.File,
538
+ file: () => Ts.Keyword.File,
539
+ "date-time": () => Ts.Keyword.String,
540
+ time: () => Ts.Keyword.String,
541
+ date: () => Ts.Keyword.String,
542
+ duration: () => Ts.Keyword.String,
543
+ email: () => Ts.Keyword.String,
544
+ "idn-email": () => Ts.Keyword.String,
545
+ "idn-hostname": () => Ts.Keyword.String,
546
+ ipv4: () => Ts.Keyword.String,
547
+ ipv6: () => Ts.Keyword.String,
548
+ uuid: () => Ts.Keyword.String,
549
+ uri: () => Ts.Keyword.String,
550
+ "uri-reference": () => Ts.Keyword.String,
551
+ "uri-template": () => Ts.Keyword.String,
552
+ "json-pointer": () => Ts.Keyword.String,
553
+ "relative-json-pointer": () => Ts.Keyword.String,
554
+ regex: () => Ts.Keyword.String,
555
+ },
556
+ array: ({ items, ...schemaPart }, parser) => {
557
+ const content = parser.getInlineParseContent(items);
558
+ return parser.safeAddNullToType(schemaPart, Ts.ArrayType(content));
559
+ },
560
+ };
561
+ ```
562
+
563
+ ### Other
564
+
565
+ feat: `--another-array-type` cli option (#414)
566
+ fix: path params with dot style (truck.id) (#413)
567
+
568
+ ## 10.0.3
569
+
570
+ fix: CRLF -> LF (#423)
571
+ docs: add docs for addReadonly nodeJS api flag (#425)
572
+ chore: remove useless trailing whitespaces which make test edit harder (thanks @qboot, #422)
573
+ internal: add test snapshots (git diff + nodejs assertions)
574
+ chore: add logging (project version, node version, npm version)
575
+
576
+ ## 10.0.2
577
+
578
+ fix: host.fileExists is not a function
579
+ fix: other problems linked with new typescript version (4.8.\*) (thanks @elkeis, @Jnig)
580
+ fix: problem with required nested properties based on root required properties list
581
+ fix: fetch http client headers content type priority
582
+ fix: fs.rmSync (thanks @smorimoto)
583
+ fix: locally overridden security schemes (security flag) (#418, thanks @EdwardSalter)
584
+ docs: add documentation for `unwrapResponseData` nodejs option (thanks @simowe)
585
+ BREAKING_CHANGE: rename `.eta` file extensions to `.ejs`. Backward capability should be existed.
586
+ fix: problem with `--sort-types` option
587
+
588
+ ## 10.0.\*
589
+
590
+ fix: problem with default http request headers in axios client
591
+
592
+ ## 10.0.1
593
+
594
+ - fix problem linked with [this.name is not a function](https://github.com/acacode/swagger-typescript-api/issues/381)
595
+ - [internal] add cli tests
596
+ - fix problem with not correct working the `--no-client` option
597
+ - separate data-contracts.ejs onto 4 pieces (enum, interface, type, jsdoc)
598
+
599
+ ## 10.0.0
600
+
601
+ - `--extract-response-body` option - extract response body type to data contract
602
+ - `--extract-response-error` option - extract response error type to data contract
603
+ - `--add-readonly` option - generate readonly properties
604
+ - `authorizationToken` for axios fetch swagger schema request
605
+ - fix: change COMPLEX_NOT_OF to COMPLEX_NOT (internal)
606
+ - feat: improve `@deprecated` jsdoc info
607
+ - feat: improve `required` field in complex data schemas (anyOf, oneOf, allOf etc)
608
+ - feat: abortSignal for fetch http client
609
+ - chore: improve typings in index.d.ts
610
+ - fixed [Request falls if FormData attachment is File instance](https://github.com/acacode/swagger-typescript-api/issues/293)
611
+ - fixed [Response format - global default or override ?](https://github.com/acacode/swagger-typescript-api/issues/251)
612
+
613
+ > Co-authored-by: Sergey S. Volkov <js2me@outlook.com>
614
+ > Co-authored-by: Xavier Cassel <57092100+xcassel@users.noreply.github.com>
615
+ > Co-authored-by: cassel <xavier.cassel35@gmail.com>
616
+ > Co-authored-by: Adrian Wieprzkowicz <Argeento@users.noreply.github.com>
617
+ > Co-authored-by: EvgenBabenko <evgen.babenko@gmail.com>
618
+ > Co-authored-by: RoCat <catoio.romain@gmail.com>
619
+ > Co-authored-by: rcatoio <rcatoio@doubletrade.com>
620
+ > Co-authored-by: 卡色 <cipchk@qq.com>
621
+ > Co-authored-by: 江麻妞 <50100681+jiangmaniu@users.noreply.github.com>
622
+ > Co-authored-by: Kasper Moskwiak <kasper.moskwiak@gmail.com>
623
+ > Co-authored-by: Ben Watkins <ben@outdatedversion.com>
624
+ > Co-authored-by: bonukai <bonukai@protonmail.com>
625
+ > Co-authored-by: baggoedw <92381702+baggoedw@users.noreply.github.com>
626
+ > Co-authored-by: Marcus Dunn <51931484+MarcusDunn@users.noreply.github.com>
627
+ > Co-authored-by: Daniele De Matteo <daniele@kuama.net>
628
+ > Co-authored-by: Daniel Playfair Cal <daniel.playfair.cal@gmail.com>
629
+ > Co-authored-by: Anders Cassidy <anders.cassidy@dailypay.com>
630
+ > Co-authored-by: Daniel Playfair Cal <dcal@atlassian.com>
631
+
632
+ ## 9.2.0
633
+
634
+ Features:
635
+
636
+ - full response typing for status code, data and headers. (#272, thanks @rustyconover)
637
+ - --unwrap-response-data to unwrap the data item from the response (#268, thanks @laktak)
638
+
639
+ Fixes:
640
+
641
+ - fix: formdata in axios template (#277, thanks @tiagoskaneta)
642
+
643
+ ## 9.1.2
644
+
645
+ Fixes:
646
+
647
+ - Bug with --single-http-client and private `http` property
648
+
649
+ ## 9.1.1
650
+
651
+ Fixes:
652
+
653
+ - Bug with nested objects in FormData (issue #262, thanks @avlnche64)
654
+
655
+ ## 9.1.0
656
+
657
+ Fixes:
658
+
659
+ - Critical bug linked with `templateRequire` in ETA templates
660
+ - Critical bugs linked with `--type-prefix`, `--type-suffix`
661
+
662
+ Internal:
663
+
664
+ - Improve manual testing scripts
665
+
666
+ ## 9.0.2
667
+
668
+ Fixes:
669
+
670
+ - 9.0.1 won't build with tsc when imported (thanks @mastermatt)
671
+
672
+ ## 9.0.1
673
+
674
+ Fixes:
675
+
676
+ - Can't compile 9.0.0 version (thanks @Nihisil )
677
+
678
+ ## 9.0.0
679
+
680
+ NOTE: This version is not compatible with previous templates (removed `route.request.params`, `apiConfig.props`, `apiConfig.generic`, `apiConfig.description`, `apiConfig.hasDescription`)
681
+
682
+ Fixes:
683
+
684
+ - Consider 2xx a successful status (thanks @wyozi)
685
+ - GET method query option bug (thanks @rhkdgns95, @SaschaGalley)
686
+ - `silent` property missed in `.d.ts` file (thanks @mastermatt)
687
+ - axios file upload `formData` type (thanks @guhyeon)
688
+ - make property `instance` to public in axios http client (It can be helpful in #226)
689
+ - variable name "params" doesn't uniq (thanks @mixalbl4-127 )
690
+
691
+ Features:
692
+
693
+ - `--disableProxy` option (thanks @kel666)
694
+ - `--extract-request-body` option. Allows to extract request body type to data contract
695
+ - Add TSDoc tag for deprecated route (thanks @wyozi)
696
+
697
+ ## 8.0.3
698
+
699
+ - Fixes encoding array query params in `fetch` http templates (thanks @prog13)
700
+
701
+ ## 8.0.2
702
+
703
+ Fixes:
704
+
705
+ - Wrong working the `format` option in `fetch` http client
706
+
707
+ ## 8.0.1
708
+
709
+ Fixes:
710
+
711
+ - Not working `customFetch`
712
+ Error: `Failed to execute 'fetch' on 'Window': Illegal invocation`
713
+
714
+ ## 8.0.0
715
+
716
+ BREAKING_CHANGES:
717
+
718
+ - remove default `json` format of the response type (both for `axios` and `fetch` http clients) (issue #213, thanks @po5i)
719
+
720
+ Features:
721
+
722
+ - Allow passing custom fetch function (`fetch` http client only)
723
+ - Allow to set global response type format through `HttpClient` constructor
724
+ Example:
725
+
726
+ ```ts
727
+ const httpClient = new HttpClient({ format: "json" });
728
+ // all request responses will been formatted as json
729
+ ```
730
+
731
+ Fixes:
732
+
733
+ - Missing `schema.$ref` in inline enum schemas
734
+ - Array query param values are serialized with the (non-default) comma separated style (issue #222, thanks @Styn, PR #223)
735
+ - TypeScript error "TS6133: 'E' is declared but its value is never read." (`axios` http client) (issue #220, thanks @pmbednarczyk )
736
+
737
+ ## 7.0.1
738
+
739
+ Fixes:
740
+
741
+ - "securityWorker" is only used if "secure" option is specified on each request (issue #212, thanks @dkamyshov)
742
+ NOTE: added global `secure` option for `axios` http client
743
+ - `index.d.ts` file (add `rawModelTypes`)
744
+
745
+ ## 7.0.0
746
+
747
+ BREAKING_CHANGES:
748
+
749
+ - format `namespace` name in `--route-types` as camelCase with upper first capitalized letter
750
+ `foo_bar` -> `FooBar`
751
+
752
+ Fixes:
753
+
754
+ - Incorrect working the `--route-types` option with `--modular` option (route types should be splitted on files)
755
+ - Fix critical bug linked with enums with boolean type (thanks @haedaal)
756
+
757
+ Features:
758
+
759
+ - Ability to return `false` in `onCreateRoute` hook, it allow to ignore route
760
+ - Add output util functions
761
+
762
+ ```ts
763
+ createFile: (params: {
764
+ path: string;
765
+ fileName: string;
766
+ content: string;
767
+ withPrefix?: boolean;
768
+ }) => void;
769
+ renderTemplate: (
770
+ templateContent: string,
771
+ data: Record<string, unknown>,
772
+ etaOptions?: import("eta/dist/types/config").PartialConfig
773
+ ) => string;
774
+ getTemplate: (params: {
775
+ fileName?: string;
776
+ name?: string;
777
+ path?: string;
778
+ }) => string
779
+ formatTSContent: (content: string) => Promise<string>;
780
+
781
+
782
+ // ...
783
+
784
+ generateApi({ /* ... */ }).then(({ createFile, renderTemplate, getTemplate }) => {
785
+ // do something
786
+ })
787
+ ```
788
+
789
+ ## 6.4.2
790
+
791
+ Fixes:
792
+
793
+ - Bug with missing `name` property in in-path requests parameters
794
+ - Problem with usage `--route-types` with `--modular` option (mising import data contracts)
795
+
796
+ ## 6.4.1
797
+
798
+ Fixes:
799
+
800
+ - Bug with axios headers (thanks @mutoe)
801
+
802
+ ## 6.4.0
803
+
804
+ Features:
805
+
806
+ - `onFormatRouteName(routeInfo: RawRouteInfo, templateRouteName: string)` hook. Allows to format route name, as you like :)
807
+
808
+ Fixes:
809
+
810
+ - Bug with wrong complex types (anyOf, oneOf, allOf) when some child schema contains only description
811
+ ![example](./assets/changelog_assets/fixComplexTypeAny.jpg)
812
+ - Bug with number enums which have `x-enumNames`
813
+ - Problem with not existing `title` property in `info`
814
+
815
+ Minor:
816
+
817
+ - Improve description for complex types
818
+ - Improve description in single api file
819
+
820
+ ## 6.3.0
821
+
822
+ Features:
823
+
824
+ - `--type-suffix` option. Allows to set suffix for data contract name. (issue #191, thanks @the-ult)
825
+ - `--type-prefix` option. Allows to set prefix for data contract name. (issue #191, thanks @the-ult)
826
+ Examples [here](./spec/typeSuffixPrefix/schema.ts)
827
+ - `onFormatTypeName(usageTypeName, rawTypeName, schemaType)` hook. Allow to format data contract names as you want.
828
+
829
+ Internal:
830
+
831
+ - rename and split `checkAndRenameModelName` -> `formatModelName`, `fixModelName`
832
+
833
+ ## 6.2.1
834
+
835
+ Fixes:
836
+
837
+ - missing `generateUnionEnums?: boolean;` in `index.d.ts` file (thanks @artsaban)
838
+ - missing default params to axios http client (`--axios`) (issue #192, thanks @Nihisil)
839
+
840
+ ## 6.2.0
841
+
842
+ Features:
843
+
844
+ - `--module-name-first-tag` option. Splits routes based on the first tag (thanks @jnpoyser)
845
+
846
+ ## 6.1.2
847
+
848
+ Fixes:
849
+
850
+ - Problems with using both `--axios` and `--modular` options together (TS, `organizeImports` crashed the codegeneration)
851
+
852
+ ## 6.1.1
853
+
854
+ Fixes:
855
+
856
+ - Problems with `--axios` option
857
+ - ignoring `path`, `format`, `type` payload properties in `request()` method of `HttpClient`
858
+ - Missing `format` property for requests in `--modular` option
859
+
860
+ ## 6.1.0
861
+
862
+ Features:
863
+
864
+ - `--silent` option. Output only errors to console (default: false)
865
+
866
+ Fixes:
867
+
868
+ - Bug with `kebab-case` path params (issue #184, thanks @Mr-sgreen)
869
+ - Typings for `--js` option
870
+
871
+ ## 6.0.0
872
+
873
+ ### BREAKING_CHANGES:
874
+
875
+ - Ability to override only one template (issue #166, thanks @Nihisil)
876
+ - removed `TPromise` type for `--responses` options (perf. problem, issue #182, thanks @mixalbl4-127)
877
+ - breaking changes in `http-client.eta`
878
+ - `securityWorker` now can return `Promise<RequestParams | void> | RequestParams | void`
879
+
880
+ ### Features:
881
+
882
+ - template path prefixes `@base`, `@default`, `@modular` (using in Eta templates, `includeFile()`, see README.md)
883
+ - `--axios` option for axios http client (issue #142, thanks @msklvsk, @mixalbl4-127 )
884
+
885
+ ## 5.1.7
886
+
887
+ ### Fixes:
888
+
889
+ - Do not fail if template file does not exist (issue #166, thanks @armsnyder )
890
+ Caveat: With this fix it will still error if the overridden template uses `includeFile` on a template file that is not overridden
891
+
892
+ ## 5.1.6
893
+
894
+ ### Fixes:
895
+
896
+ - The contentFormatter for ContentType:Json does not correctly format strings (issue #176, thanks @Styn)
897
+
898
+ ## 5.1.5
899
+
900
+ ### Fixes:
901
+
902
+ - ContentType.FormData no longer sets the correct boundary (issue #172, thanks @Styn)
903
+
904
+ ## 5.1.4
905
+
906
+ ### Fixes:
907
+
908
+ - header overwrite in `default` and `modular` API templates (issue #171 by @Styn, thanks @emilecantin for PR with fix)
909
+
910
+ ## 5.1.3
911
+
912
+ ### Fixes:
913
+
914
+ - Ignored `x-nullable` field
915
+ - Schema type names which starts with number or special characters
916
+
917
+ ## 5.1.2
918
+
919
+ ### Fixes:
920
+
921
+ - Linter disable rules is not working (issue #164, thanks @Haritaso)
922
+
923
+ ## 5.1.1
924
+
925
+ ### Fixes:
926
+
927
+ - The HttpResponse type is no longer exported from http-client (issue #161, thanks @Styn)
928
+
929
+ ## 5.1.0
930
+
931
+ ### Fixes:
932
+
933
+ - Bug with optional nested properties of object schema type (issue #156, thanks @Fabiencdp)
934
+
935
+ ### Features:
936
+
937
+ - `onCreateRouteName(routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo): RouteNameInfo | void` hook
938
+ Which allows to customize route name without customizing `route-name.eta` template
939
+ - Improved content kinds for request infos
940
+ - `--single-http-client` option which allows to send HttpClient instance to Api constructor and not to create many count of HttpClient instances with `--modular` api (issue #155)
941
+
942
+ ### Minor:
943
+
944
+ - A bit improve type declaration file (index.d.ts) for this tool
945
+ - make exportable `ApiConfig` interface
946
+
947
+ ### Internal:
948
+
949
+ - clearing `routeNameDuplicatesMap` before each `parseRoutes()` function call
950
+ - Changed templates:
951
+ - `http-client.eta`
952
+ - `procedure-call.eta`
953
+ - `api.eta`
954
+
955
+ ## 5.0.0
956
+
957
+ ### Fixes:
958
+
959
+ - Request content types auto substitution
960
+ i.e. if request body is form data, then request body content type will be `multipart/form-data`
961
+ - Strange method name (issue #152, thanks @RoXuS)
962
+ - Hardcoded Content-Type causes issues with some endpoints (issue #153, thanks @po5i)
963
+ - Critical bug with `:paramName` path params (issue #154)
964
+
965
+ ### Features:
966
+
967
+ - Ability to provide custom formatting `fetch` response
968
+ - `"IMAGE"` content kind for response\request data objects
969
+ - `RequestParams` `RequestHeaders` types for `--route-types` (`routeTypes: true`) option (issue #150, thanks @Fabiencdp )
970
+ - `--default-response` option. Allows to set default type for empty response schema (default: `void`) (based on issue #14)
971
+ - Request cancellation support (issue #96, thanks @ApacheEx)
972
+ `RequestParams` type now have the `cancelToken` field
973
+ `HttpClient` instance now have the `abortRequest(cancelToken)` method
974
+
975
+ ### BREAKING_CHANGES:
976
+
977
+ - Fully refactored `http-client.eta` template, make it more flexible and simpler.
978
+ `HttpClient["request"]` takes one argument with type `FullRequestParams`
979
+ (previously it takes many count of arguments which was not flexible)
980
+ - Changed the default response body type from `any` to `void` (issue #14)
981
+
982
+ ### Internal:
983
+
984
+ - Changed templates:
985
+ - `http-client.eta`
986
+ - `procedure-call.eta`
987
+ - `api.eta`
988
+
989
+ This version works with previous templates.
990
+
991
+ ## 4.4.0
992
+
993
+ ### Fixes:
994
+
995
+ - Client generation for `Content-Type: application/x-www-form-urlencoded` (issue #146, thanks @Larox)
996
+
997
+ ### Internal:
998
+
999
+ - Changed templates:
1000
+ - `http-client.eta`
1001
+ - `procedure-call.eta`
1002
+
1003
+ # 4.3.0
1004
+
1005
+ ### Fixes:
1006
+
1007
+ - enum + nullable: true doesn't compute the good type (issue #145, thanks @RoXuS)
1008
+ - Underscores are omitted from enum keys (issue #108, thanks @eolant)
1009
+ - CLI silently fails if the directory to put new files in doesn't exist yet (issue #141, thanks @Styn)
1010
+
1011
+ ### Features:
1012
+
1013
+ - Improved type description
1014
+
1015
+ ### Internal:
1016
+
1017
+ - dependencies update:
1018
+ - `"js-yaml": "^4.0.0"` (`"^3.14.1"`)
1019
+ - `"make-dir": "^3.1.0"`
1020
+ - `"swagger2openapi": "^7.0.5"` (`"^7.0.4"`)
1021
+ - Difference in templates:
1022
+ - `data-contracts.eta`
1023
+ ![dataContracts430](./assets/changelog_assets/http-client-template-diff-4.3.0.jpg)
1024
+
1025
+ ## 4.2.0
1026
+
1027
+ ### Features:
1028
+
1029
+ - new hook `onCreateRequestParams` which allows modify request params (`--extract-request-params` option) before sending it to route info
1030
+ ![onCreateRequestParams](./assets/changelog_assets/onCreateRequestParamsHook.jpg)
1031
+ How to use:
1032
+
1033
+ ```ts
1034
+ generateApi({
1035
+ // ... your config,
1036
+ hooks: {
1037
+ onCreateRequestParams: (rawType) => {
1038
+ if (Object.keys(rawType.properties).length > 1) return rawType;
1039
+
1040
+ return rawType;
1041
+ },
1042
+ },
1043
+ });
1044
+ ```
1045
+
1046
+ - response content types (array of string like `application/json`, `image/png`) which allows to customize declaration of request response
1047
+ Exist in `procedure-call.eta` template `it.route.response.contentTypes`
1048
+
1049
+ ### Internal:
1050
+
1051
+ - Difference in templates:
1052
+ - `procedure-call.eta`
1053
+ ![procedureCallEta1](./assets/changelog_assets/changes_procedure_call_1.jpg)
1054
+
1055
+ ## 4.1.0
1056
+
1057
+ ### Features:
1058
+
1059
+ - Improve `require()` function used in ETA templates (using relative path imports)
1060
+ - `--clean-output` option.
1061
+ clean output folder before generate api
1062
+
1063
+ ### Fixes:
1064
+
1065
+ - Error: `Unexpected token =` (Issue #136, Thanks @jlow-mudbath)
1066
+ - Output folder creation (Issue #137, Thanks @Rinta01)
1067
+ Create output folder if it is not exist
1068
+
1069
+ ## 4.0.5
1070
+
1071
+ ### BREAKING_CHANGE:
1072
+
1073
+ - remove `'prettier-plugin-organize-imports'` dependency from package
1074
+
1075
+ ### Fixes:
1076
+
1077
+ - issue #134 (Thanks @mrfratello)
1078
+
1079
+ ## 4.0.4
1080
+
1081
+ ### Features:
1082
+
1083
+ - add `require()` to template `utils` object
1084
+
1085
+ ### Docs:
1086
+
1087
+ - add information about contributors
1088
+
1089
+ ## 4.0.3
1090
+
1091
+ ### Features:
1092
+
1093
+ - `--disableStrictSSL` option for disable strict SSL statement with fetching swagger schema. (Thanks @kel666 for PR with feature request)
1094
+ This option fix problem #114
1095
+
1096
+ ## 4.0.2
1097
+
1098
+ ### Fixes:
1099
+
1100
+ - `Unexpected token '.'` on v4 (Thanks @savingprivatebryan for issue #111)
1101
+ Replaced all new syntax sugar like `?.` or `??` to prev. alternatives for support nodejs 12
1102
+
1103
+ ## 4.0.1
1104
+
1105
+ ### Fixes:
1106
+
1107
+ - `Cannot find module 'prettier-plugin-organize-imports'` #109
1108
+
1109
+ ## 4.0.0
1110
+
1111
+ ### BREAKING_CHANGES:
1112
+
1113
+ - Migrate from [mustache](https://mustache.github.io/) template engine to [ETA](https://eta.js.org/) template engine. (Thanks @Fl0pZz)
1114
+ - Critical change in `HttpResponse` type (Remove `D | null`, `E | null` unions)
1115
+
1116
+ ```diff
1117
+ interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
1118
+ - data: D | null;
1119
+ + data: D;
1120
+ - error: E | null;
1121
+ + error: E;
1122
+ }
1123
+ ```
1124
+
1125
+ ### Features:
1126
+
1127
+ - `--modular` option. Allows to generate api class per module name.
1128
+ Example: [here](./tests/spec/modular)
1129
+ - new templates on [ETA](https://eta.js.org/) (enhanced EJS) which can improve your templates! (Thanks @Fl0pZz)
1130
+ [ETA extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=shadowtime2000.eta-vscode) (thanks @shadowtime2000)
1131
+ Also moved out to templates:
1132
+
1133
+ - `procedure-call.eta` (request api method template)
1134
+ - `route-name.eta` (api method name template)
1135
+ - `route-docs.eta` (api method docs template)
1136
+
1137
+ No worry about strange syntax it is very simple in usage :)
1138
+
1139
+ - Optional templates feature (Except templates using in `includeFile` `ETA` directive)
1140
+ Now you can store only the `ETA` templates which you need to change for yourself.
1141
+ - `--extract-request-params` option. Generate path and query request params data contract and modify request payload args
1142
+ Example:
1143
+ ![extract-request-params](./assets/changelog_assets/extractRequestParams.jpg)
1144
+ - Improve `data-contracts.eta` template. Added more power :)
1145
+ - Add `extraTemplates` property for `generateApi()`. Allows to generate extra files via this tool.
1146
+ - Add `hooks` property for `generateApi()`
1147
+ ```ts
1148
+ hooks?: Partial<{
1149
+ onCreateComponent: (component: SchemaComponent) => SchemaComponent | void;
1150
+ onParseSchema: (originalSchema: any, parsedSchema: any) => any | void;
1151
+ onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | void;
1152
+ /** Start point of work this tool (after fetching schema) */
1153
+ onInit?: <C extends GenerateApiConfiguration["config"]>(configuration: C) => C | void;
1154
+ /** Allows to customize configuration object before sending it to templates. */
1155
+ onPrepareConfig?: <C extends GenerateApiConfiguration>(currentConfiguration: C) => C | void;
1156
+ }>;
1157
+ ```
1158
+ ```ts
1159
+ generateApi({
1160
+ input: "./schema.json",
1161
+ output: "./__generated__",
1162
+ hooks: {
1163
+ onCreateComponent(component) {
1164
+ // do something
1165
+ return component;
1166
+ },
1167
+ // ...
1168
+ },
1169
+ });
1170
+ ```
1171
+
1172
+ ### Internal:
1173
+
1174
+ - Update all dependencies to latest
1175
+
1176
+ ### Fixes:
1177
+
1178
+ - `x-enumNames` support for enums
1179
+ - Problem of complex types (`oneOf`, `allOf`) with `properties` field
1180
+ - `additionalProperties: true` should make `[key: string]: any` for object types (Thanks @brookjordan for issue #103)
1181
+
1182
+ ### Common:
1183
+
1184
+ - `HttpClient` is exportable by default
1185
+ - Improve typings when use `swagger-typescript-api` with NodeJS (`index.d.ts`)
1186
+
1187
+ ## 3.1.2
1188
+
1189
+ ### Fixes:
1190
+
1191
+ - axios vulnerability (#101 issue, thanks @Mvbraathen)
1192
+
1193
+ ## 3.1.1
1194
+
1195
+ ### Fixes:
1196
+
1197
+ - `name.includes is not a function` (issue #98)
1198
+
1199
+ ## 3.1.0
1200
+
1201
+ ### Features:
1202
+
1203
+ - `--moduleNameIndex` option. determines which path index should be used for routes separation (Thanks @nikalun)
1204
+ Examples:
1205
+ GET:api/v1/fruites/getFruit -> index:2 -> moduleName -> fruites
1206
+ GET:api/v1/fruites/getFruit -> index:0 -> moduleName -> api
1207
+
1208
+ ## 3.0.1
1209
+
1210
+ ### Fixes:
1211
+
1212
+ - invalid default templates path (#92, thanks @larrybotha for quick fix)
1213
+
1214
+ ## 3.0.0
1215
+
1216
+ ### BREAKING_CHANGES:
1217
+
1218
+ - Renamed mustache templates:
1219
+ - `api.mustache` -> `data-contracts.mustache`
1220
+ - `client.mustache` -> `http.client.mustache` + `api.mustache`
1221
+ - Split the `client.mustache` template into two parts: `http-client.mustache` and `api.mustache`
1222
+
1223
+ ### Fixes:
1224
+
1225
+ - Fixed unsafe clone() of Response causing json() hang. (Thanks @Benjamin-Dobell)
1226
+
1227
+ ## 2.0.0
1228
+
1229
+ ### Features:
1230
+
1231
+ - `--js` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/79)
1232
+
1233
+ ### BREAKING_CHANGES:
1234
+
1235
+ - Requests returns `Promise<HttpResponse<Data, Error>>` type.
1236
+ `HttpResponse` it is [Fetch.Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) wrapper with fields `data` and `error`
1237
+ Example:
1238
+
1239
+ ```ts
1240
+ const api = new Api();
1241
+
1242
+ //
1243
+ const response: HttpResponse<Data, Error> = await api.fruits.getAll();
1244
+
1245
+ response.data; // Data (can be null if response.ok is false)
1246
+ response.error; // Error (can be null if response.ok is true)
1247
+ ```
1248
+
1249
+ - Breaking changes in the `client.mustache` template. Needs to update local custom templates.
1250
+
1251
+ ### Fixes:
1252
+
1253
+ - Security configuration in methods. When the security definition is in the main configuration of the swagger definition
1254
+
1255
+ ## 1.12.0
1256
+
1257
+ ### Features:
1258
+
1259
+ - Can provide ability to generate from swagger JSON directly not from a file? #69 (Thanks @JennieJi)
1260
+
1261
+ ### Fixes:
1262
+
1263
+ - handling `x-omitempty` property for definition properties #68
1264
+ - Additional properties map to empty interfaces (OpenAPI v3) #76
1265
+ - Pattern fields in Path Item Object are treated as operations #75
1266
+ - Remove const enum from default template #73
1267
+ - enums with spaces throw an error #71
1268
+
1269
+ ## 1.11.0
1270
+
1271
+ ### Features:
1272
+
1273
+ - Improve the naming of model types ([#65 issue](https://github.com/acacode/swagger-typescript-api/issues/65))
1274
+
1275
+ ## 1.10.0
1276
+
1277
+ ### Features:
1278
+
1279
+ - `--templates` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/54)
1280
+ Provide custom `mustache` templates folder which allows to generate custom code (models, Api class, routes)
1281
+ - `--union-enums` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/58)
1282
+ Allows to generate all enums as union types.
1283
+ For example, schema part:
1284
+ ```
1285
+ "StringEnum": {
1286
+ "enum": ["String1", "String2", "String3", "String4"],
1287
+ "type": "string"
1288
+ }
1289
+ ```
1290
+ will be converted into:
1291
+ `export type StringEnum = "String1" | "String2" | "String3" | "String4";
1292
+ `
1293
+
1294
+ ## 1.8.4
1295
+
1296
+ ### Fixes:
1297
+
1298
+ - Multiple types for a property in Swagger 2 are not handled correctly ([#55 issue](https://github.com/acacode/swagger-typescript-api/issues/55))
1299
+
1300
+ ## 1.8.3
1301
+
1302
+ ### Fixes:
1303
+
1304
+ - Generating invalid code in composed schema contexts ([#51 issue](https://github.com/acacode/swagger-typescript-api/issues/51))
1305
+ ```yaml
1306
+ components:
1307
+ schemas:
1308
+ Test:
1309
+ type: object
1310
+ allOf:
1311
+ - type: object
1312
+ properties:
1313
+ x:
1314
+ type: array
1315
+ items:
1316
+ type: string
1317
+ enum:
1318
+ - A-B
1319
+ - type: object
1320
+ properties:
1321
+ y:
1322
+ type: string
1323
+ ```
1324
+ ```ts
1325
+ export type Test = XAB & { y?: string };
1326
+ ```
1327
+
1328
+ ## 1.8.2
1329
+
1330
+ ### Fixes:
1331
+
1332
+ - Broken types for arrays of union types ([issue](https://github.com/acacode/swagger-typescript-api/issues/49))
1333
+
1334
+ ## 1.8.1
1335
+
1336
+ ### Fixes:
1337
+
1338
+ - form data request body (request body content `multipart/form-data`)
1339
+
1340
+ ### Minor:
1341
+
1342
+ - inline comments of the data contract type properties
1343
+ ![one line comments](./assets/changelog_assets/one-line-comments.jpg)
1344
+ - remove `Array<T>` type usage (now the more simple type `T[]`)
1345
+
1346
+ ## 1.8.0
1347
+
1348
+ ### Features:
1349
+
1350
+ - **Partially** support FormData body types
1351
+ - Support to generate query params of nested query objects (Partial fix of [this issue](https://github.com/acacode/swagger-typescript-api/issues/45))
1352
+
1353
+ ## 1.7.2
1354
+
1355
+ ### Fixes:
1356
+
1357
+ - Critical bug with converting inline object into name of type for request body.
1358
+ - Fix bug when path parameters is not set but contains in endpoint url.
1359
+ ![path params bug 1](./assets/changelog_assets/bug-with-no-path-args.jpg)
1360
+ ![path params bug 2](./assets/changelog_assets/bug-with-no-path-args2.jpg)
1361
+
1362
+ ## 1.7.0
1363
+
1364
+ ### Breaking Changes:
1365
+
1366
+ - Remove `title` and `version` public Api class properties (moved it to Api class JSDOC)([fixes this issue](https://github.com/acacode/swagger-typescript-api/issues/41))
1367
+ ![removed title and version properties](./assets/changelog_assets/removed-title-version-props.jpg)
1368
+ - Move out all http client handlers/properties into `HttpClient` local class in module
1369
+ ![http-client-class1](./assets/changelog_assets/http-client-class1.jpg)
1370
+ ![http-client-class2](./assets/changelog_assets/http-client-class2.jpg)
1371
+
1372
+ ### Chore:
1373
+
1374
+ - default value for `SecurityDataType` Api class generic type
1375
+
1376
+ ## 1.6.3
1377
+
1378
+ ### Fixes:
1379
+
1380
+ - Handling of nullable for $ref in OpenAPI 3.0 ([issue](https://github.com/acacode/swagger-typescript-api/issues/39))
1381
+ Plus based on this issue was fixed most other problems with using `required` and `nullable` properties
1382
+
1383
+ ## 1.6.2
1384
+
1385
+ ### Fixes:
1386
+
1387
+ - Nullable not included in type definition ([issue](https://github.com/acacode/swagger-typescript-api/issues/36))
1388
+
1389
+ ### Internal:
1390
+
1391
+ - Update `swagger2openapi`(`6.0.0`) dependency
1392
+
1393
+ ## 1.6.1
1394
+
1395
+ ### Internal:
1396
+
1397
+ - Update `prettier`(`2.0.2`), `swagger2openapi`(`5.4.0`) dependencies
1398
+
1399
+ ## 1.6.0
1400
+
1401
+ ### Features:
1402
+
1403
+ - Improvenment in optional request params (request body, query params, path params)
1404
+
1405
+ ### Fixes:
1406
+
1407
+ - Fix bug when `path` request param have the same name as `query`
1408
+ - Fix bug when `path` request param have the same name as `params`
1409
+
1410
+ ### Minor/Internal:
1411
+
1412
+ - changed `addQueryParams()` method
1413
+ - up `swagger2openapi` dependency version to `5.3.4`
1414
+
1415
+ ## 1.5.0
1416
+
1417
+ ### Features:
1418
+
1419
+ - Add `prettier` for beautify output typescript api module
1420
+ - Support `additionalProperties` type data
1421
+ ![additional properties](./assets/changelog_assets/additional-properties-types.jpg)
1422
+
1423
+ ### Fixes:
1424
+
1425
+ - Fix problem with array `type` definitions without `type` property([#26](https://github.com/acacode/swagger-typescript-api/issues/26))
1426
+
1427
+ ## 1.4.1
1428
+
1429
+ ### Fixes:
1430
+
1431
+ - Fix TS problem with `addQueryParams` Api class method (issue [#22](https://github.com/acacode/swagger-typescript-api/issues/22), thanks [genaby](https://github.com/genaby))
1432
+
1433
+ ## 1.4.0
1434
+
1435
+ ### Breaking Changes:
1436
+
1437
+ - Rename default typescript output api file name (prev `api.ts`, now `Api.ts`)
1438
+ Features:
1439
+ - `-d, --default-as-success` option. Allows to use "default" status codes as success response type
1440
+ - `-r, --responses` option. Response declarations in request rescription
1441
+ This option adds comments of the possible responses from request
1442
+ ![responses comments](./assets/changelog_assets/responses-comments.jpg)
1443
+ Also typings for `.catch()` callback
1444
+ ![responses catch types](./assets/changelog_assets/responses-catch-types.jpg)
1445
+ - Improve response body type definitions
1446
+ - Types for bad responses
1447
+ Changes:
1448
+ - \[minor\] fix jsdoc comments space
1449
+ ![right comments space](./assets/changelog_assets/right-comments-space.jpg)
1450
+
1451
+ ## 1.3.0
1452
+
1453
+ ### Features:
1454
+
1455
+ - Api module description from schema info
1456
+ ![api description](./assets/changelog_assets/api-module-description.jpg)
1457
+ - Generate API type declarations (CLI flag `--route-types`, thanks [azz](https://github.com/azz))
1458
+ ![route types](./assets/changelog_assets/route-types.jpg)
1459
+ - Ability to not generate clint API class (CLI flag `--no-client`, thanks [azz](https://github.com/azz))
1460
+
1461
+ ### Fixes:
1462
+
1463
+ - Improve response body type definition
1464
+
1465
+ ### Internal:
1466
+
1467
+ - refactored `generate` and `validate` test scripts
1468
+
1469
+ ## 1.2.6
1470
+
1471
+ Fixes: create api without `-o` option (use default `./` output)
1472
+
1473
+ ## 1.2.5
1474
+
1475
+ Features: better naming of routes without `operationId`
1476
+ ![route naming](./assets/changelog_assets/1.2.5_route_naming.jpg)
1477
+ Changes: rename `@security true` -> `@secure`, `@duplicate true` -> `@duplicate`
1478
+ Fixes: Support generated swagger schemes from tsoa 3.x with complex types (Omit, Pick, etc)
1479
+
1480
+ ## 1.2.4
1481
+
1482
+ Features: add .d.ts file into npm package
1483
+ Changes: update help block in CLI
1484
+ Internal: add greenkeeper, update npm keywords
1485
+
1486
+ ## 1.2.3
1487
+
1488
+ Features: @summary, @description comments at each route
1489
+ Fixes: parsing schema without routes
1490
+ Changes: update documentation
1491
+ Internal: add anyOf, allOf test schemas, slack notifications in CI
1492
+
1493
+ ## 1.2.2
1494
+
1495
+ Fixes: fix complex types (oneOf, anyOf), required fields of object type was not required
1496
+
1497
+ ## 1.2.0
1498
+
1499
+ Changes: rename `ApiParams` to `RequestParams`, secure module always exist in generated API module, update documentation
1500
+ Fixes: Query params was all required, parse yaml files, typescript minor warnings (;)
1501
+ Internal: test schemas + manual testing, add travis CI/CD
1502
+
1503
+ ## 1.1.0
1504
+
1505
+ Fixes: catching http errors with use API module
1506
+
1507
+ ## 1.0.9
1508
+
1509
+ Features: add description to interfaces and their fields
1510
+ Changes: update documentation
1511
+
1512
+ ## 1.0.8
1513
+
1514
+ Changes: update documentation
1515
+
1516
+ ## 1.0.7
1517
+
1518
+ Changes: update documentation (+ add logo), add comment about author in generated module
1519
+
1520
+ ## 1.0.6
1521
+
1522
+ Fixes: route naming, http(s) requests for getting swagger schema, integer enums
1523
+ Changes: include only required files into npm pacakge
1524
+
1525
+ ## 1.0.5
1526
+
1527
+ Changes: update documentation
1528
+
1529
+ ## 1.0.4
1530
+
1531
+ Changes: disable linters rules for generated API module
1532
+ Fixes: TS issues in template
1533
+
1534
+ ## 1.0.3
1535
+
1536
+ Fixes: NodeJS main script cannot been called on Unix\* machines
1537
+ Changes: add LICENSE, update README
1538
+
1539
+ ## 1.0.2
1540
+
1541
+ Changes(Internal): change dependencies
1542
+
1543
+ ## 1.0.1
1544
+
1545
+ New features: query params, separating routes on submodules, common params in constructor, swagger v2 + yaml parsers
1546
+ Enhancements: better type extracting.
1547
+ Fixes: mustache escaping chars
1548
+ Changes: order of request params, emojis messages in console
1549
+
1550
+ ## 1.0.0
1551
+
1552
+ Initial project.