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