swagger-typescript-api 11.0.0--beta-2 → 11.0.0--beta-4

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 ADDED
@@ -0,0 +1,1091 @@
1
+ # next release
2
+
3
+ # 11.0.0
4
+
5
+ ## Breaking changes
6
+
7
+ - `data-contract-jsdoc.ejs` file uses new input structure. Please update your local copy.
8
+ - new codebase (class way)
9
+ - ability to change everything in codegen process configuration with using NodeJS Api
10
+ - ability to call `generateApi` function 2 and more times per 1 NodeJS process.
11
+
12
+ ## [feature] Ability to modify internal codegen typescript structs
13
+ Everything which creates codegen about output typescript code now contains in `Ts` field in [`src/configuration`](src/configuration.js).
14
+ And this thing is available for end user modifications with using NodeJS Cli option `codeGenConstructs`.
15
+ It contains almost all which is not contains in `.eta`\ `.ejs` templates. For example: `Record<string, any>`, `readonly typeField?: value`, etc
16
+
17
+ Structure of `Ts` property
18
+ ```ts
19
+ const Ts = {
20
+ Keyword: {
21
+ Number: "number",
22
+ String: "string",
23
+ Boolean: "boolean",
24
+ Any: "any",
25
+ Void: "void",
26
+ Unknown: "unknown",
27
+ Null: "null",
28
+ Undefined: "undefined",
29
+ Object: "object",
30
+ File: "File",
31
+ Date: "Date",
32
+ Type: "type",
33
+ Enum: "enum",
34
+ Interface: "interface",
35
+ Array: "Array",
36
+ Record: "Record",
37
+ Intersection: "&",
38
+ Union: "|",
39
+ },
40
+ CodeGenKeyword: {
41
+ UtilRequiredKeys: "UtilRequiredKeys",
42
+ },
43
+ /**
44
+ * $A[] or Array<$A>
45
+ */
46
+ ArrayType: (content) => {
47
+ if (this.anotherArrayType) {
48
+ return Ts.TypeWithGeneric(Ts.Keyword.Array, [content]);
49
+ }
50
+
51
+ return `${Ts.ExpressionGroup(content)}[]`;
52
+ },
53
+ /**
54
+ * "$A"
55
+ */
56
+ StringValue: (content) => `"${content}"`,
57
+ /**
58
+ * $A
59
+ */
60
+ BooleanValue: (content) => `${content}`,
61
+ /**
62
+ * $A
63
+ */
64
+ NumberValue: (content) => `${content}`,
65
+ /**
66
+ * $A
67
+ */
68
+ NullValue: (content) => content,
69
+ /**
70
+ * $A1 | $A2
71
+ */
72
+ UnionType: (contents) => _.join(_.uniq(contents), ` ${Ts.Keyword.Union} `),
73
+ /**
74
+ * ($A1)
75
+ */
76
+ ExpressionGroup: (content) => (content ? `(${content})` : ""),
77
+ /**
78
+ * $A1 & $A2
79
+ */
80
+ IntersectionType: (contents) => _.join(_.uniq(contents), ` ${Ts.Keyword.Intersection} `),
81
+ /**
82
+ * Record<$A1, $A2>
83
+ */
84
+ RecordType: (key, value) => Ts.TypeWithGeneric(Ts.Keyword.Record, [key, value]),
85
+ /**
86
+ * readonly $key?:$value
87
+ */
88
+ TypeField: ({ readonly, key, optional, value }) =>
89
+ _.compact([readonly && "readonly ", key, optional && "?", ": ", value]).join(""),
90
+ /**
91
+ * [key: $A1]: $A2
92
+ */
93
+ InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
94
+ /**
95
+ * $A1 = $A2
96
+ */
97
+ EnumField: (key, value) => `${key} = ${value}`,
98
+ /**
99
+ * $A0.key = $A0.value,
100
+ * $A1.key = $A1.value,
101
+ * $AN.key = $AN.value,
102
+ */
103
+ EnumFieldsWrapper: (contents) =>
104
+ _.map(contents, ({ key, value }) => ` ${Ts.EnumField(key, value)}`).join(",\n"),
105
+ /**
106
+ * {\n $A \n}
107
+ */
108
+ ObjectWrapper: (content) => `{\n${content}\n}`,
109
+ /**
110
+ * /** $A *\/
111
+ */
112
+ MultilineComment: (contents, formatFn) =>
113
+ [
114
+ ...(contents.length === 1
115
+ ? [`/** ${contents[0]} */`]
116
+ : ["/**", ...contents.map((content) => ` * ${content}`), " */"]),
117
+ ].map((part) => `${formatFn ? formatFn(part) : part}\n`),
118
+ /**
119
+ * $A1<...$A2.join(,)>
120
+ */
121
+ TypeWithGeneric: (typeName, genericArgs) => {
122
+ return `${typeName}${genericArgs.length ? `<${genericArgs.join(",")}>` : ""}`;
123
+ },
124
+ }
125
+ ```
126
+
127
+ ## [feature] Ability to modify swagger schema type/format to typescript construction translators
128
+ Swagger schema has constructions like `{ "type": "string" | "integer" | etc, "format": "date-time" | "float" | "etc" }` where field `type` is not "readable" for TypeScript.
129
+ And because of this `swagger-typescript-api` has key value group to translate swagger schema fields `type`/`format` to TypeScript constructions.
130
+ See more about [swagger schema type/format data here](https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times)
131
+ For example, current version of default configuration translates this schema
132
+ ```json
133
+ {
134
+ "type": "string",
135
+ "format": "date-time"
136
+ }
137
+ ```
138
+ translates to
139
+ ```ts
140
+ string
141
+ ```
142
+ If you need to see `Date` instead of `string` you are able to change it with using `primitiveTypeConstructs`
143
+ ```ts
144
+ generateApiForTest({
145
+ // ...
146
+ primitiveTypeConstructs: (construct) => ({
147
+ string: {
148
+ 'date-time': 'Date'
149
+ }
150
+ })
151
+ })
152
+ ```
153
+
154
+ Structure of `primitiveTypes` property
155
+ ```ts
156
+ const primitiveTypes = {
157
+ integer: () => Ts.Keyword.Number,
158
+ number: () => Ts.Keyword.Number,
159
+ boolean: () => Ts.Keyword.Boolean,
160
+ object: () => Ts.Keyword.Object,
161
+ file: () => Ts.Keyword.File,
162
+ string: {
163
+ $default: () => Ts.Keyword.String,
164
+
165
+ /** formats */
166
+ binary: () => Ts.Keyword.File,
167
+ file: () => Ts.Keyword.File,
168
+ "date-time": () => Ts.Keyword.String,
169
+ time: () => Ts.Keyword.String,
170
+ date: () => Ts.Keyword.String,
171
+ duration: () => Ts.Keyword.String,
172
+ email: () => Ts.Keyword.String,
173
+ "idn-email": () => Ts.Keyword.String,
174
+ "idn-hostname": () => Ts.Keyword.String,
175
+ ipv4: () => Ts.Keyword.String,
176
+ ipv6: () => Ts.Keyword.String,
177
+ uuid: () => Ts.Keyword.String,
178
+ uri: () => Ts.Keyword.String,
179
+ "uri-reference": () => Ts.Keyword.String,
180
+ "uri-template": () => Ts.Keyword.String,
181
+ "json-pointer": () => Ts.Keyword.String,
182
+ "relative-json-pointer": () => Ts.Keyword.String,
183
+ regex: () => Ts.Keyword.String,
184
+ },
185
+ array: ({ items, ...schemaPart }, parser) => {
186
+ const content = parser.getInlineParseContent(items);
187
+ return parser.checkAndAddNull(schemaPart, Ts.ArrayType(content));
188
+ },
189
+ }
190
+ ```
191
+
192
+ ## Other
193
+ feat: `--another-array-type` cli option (#414)
194
+ fix: path params with dot style (truck.id) (#413)
195
+
196
+
197
+
198
+ # 10.0.3
199
+ fix: CRLF -> LF (#423)
200
+ docs: add docs for addReadonly nodeJS api flag (#425)
201
+ chore: remove useless trailing whitespaces which make test edit harder (thanks @qboot, #422)
202
+ internal: add test snapshots (git diff + nodejs assertions)
203
+ chore: add logging (project version, node version, npm version)
204
+
205
+ # 10.0.2
206
+
207
+ fix: host.fileExists is not a function
208
+ fix: other problems linked with new typescript version (4.8.*) (thanks @elkeis, @Jnig)
209
+ fix: problem with required nested properties based on root required properties list
210
+ fix: fetch http client headers content type priority
211
+ fix: fs.rmSync (thanks @smorimoto)
212
+ fix: locally overridden security schemes (security flag) (#418, thanks @EdwardSalter)
213
+ docs: add documentation for `unwrapResponseData` nodejs option (thanks @simowe)
214
+ BREAKING_CHANGE: rename `.eta` file extensions to `.ejs`. Backward capability should be existed.
215
+ fix: problem with `--sort-types` option
216
+
217
+ # 10.0.*
218
+
219
+ fix: problem with default http request headers in axios client
220
+
221
+ # 10.0.1
222
+
223
+ - fix problem linked with [this.name is not a function](https://github.com/acacode/swagger-typescript-api/issues/381)
224
+ - [internal] add cli tests
225
+ - fix problem with not correct working the `--no-client` option
226
+ - separate data-contracts.ejs onto 4 pieces (enum, interface, type, jsdoc)
227
+
228
+ # 10.0.0
229
+
230
+ - `--extract-response-body` option - extract response body type to data contract
231
+ - `--extract-response-error` option - extract response error type to data contract
232
+ - `--add-readonly` option - generate readonly properties
233
+ - `authorizationToken` for axios fetch swagger schema request
234
+ - fix: change COMPLEX_NOT_OF to COMPLEX_NOT (internal)
235
+ - feat: improve `@deprecated` jsdoc info
236
+ - feat: improve `required` field in complex data schemas (anyOf, oneOf, allOf etc)
237
+ - feat: abortSignal for fetch http client
238
+ - chore: improve typings in index.d.ts
239
+ - fixed [Request falls if FormData attachment is File instance](https://github.com/acacode/swagger-typescript-api/issues/293)
240
+ - fixed [Response format - global default or override ?](https://github.com/acacode/swagger-typescript-api/issues/251)
241
+
242
+ > Co-authored-by: Sergey S. Volkov <js2me@outlook.com>
243
+ > Co-authored-by: Xavier Cassel <57092100+xcassel@users.noreply.github.com>
244
+ > Co-authored-by: cassel <xavier.cassel35@gmail.com>
245
+ > Co-authored-by: Adrian Wieprzkowicz <Argeento@users.noreply.github.com>
246
+ > Co-authored-by: EvgenBabenko <evgen.babenko@gmail.com>
247
+ > Co-authored-by: RoCat <catoio.romain@gmail.com>
248
+ > Co-authored-by: rcatoio <rcatoio@doubletrade.com>
249
+ > Co-authored-by: 卡色 <cipchk@qq.com>
250
+ > Co-authored-by: 江麻妞 <50100681+jiangmaniu@users.noreply.github.com>
251
+ > Co-authored-by: Kasper Moskwiak <kasper.moskwiak@gmail.com>
252
+ > Co-authored-by: Ben Watkins <ben@outdatedversion.com>
253
+ > Co-authored-by: bonukai <bonukai@protonmail.com>
254
+ > Co-authored-by: baggoedw <92381702+baggoedw@users.noreply.github.com>
255
+ > Co-authored-by: Marcus Dunn <51931484+MarcusDunn@users.noreply.github.com>
256
+ > Co-authored-by: Daniele De Matteo <daniele@kuama.net>
257
+ > Co-authored-by: Daniel Playfair Cal <daniel.playfair.cal@gmail.com>
258
+ > Co-authored-by: Anders Cassidy <anders.cassidy@dailypay.com>
259
+ > Co-authored-by: Daniel Playfair Cal <dcal@atlassian.com>
260
+
261
+ # 9.2.0
262
+
263
+ Features:
264
+ - full response typing for status code, data and headers. (#272, thanks @rustyconover)
265
+ - --unwrap-response-data to unwrap the data item from the response (#268, thanks @laktak)
266
+
267
+ Fixes:
268
+ - fix: formdata in axios template (#277, thanks @tiagoskaneta)
269
+
270
+ # 9.1.2
271
+
272
+ Fixes:
273
+ - Bug with --single-http-client and private `http` property
274
+
275
+ # 9.1.1
276
+
277
+ Fixes:
278
+ - Bug with nested objects in FormData (issue #262, thanks @avlnche64)
279
+
280
+ # 9.1.0
281
+
282
+ Fixes:
283
+ - Critical bug linked with `templateRequire` in ETA templates
284
+ - Critical bugs linked with `--type-prefix`, `--type-suffix`
285
+
286
+ Internal:
287
+ - Improve manual testing scripts
288
+
289
+ # 9.0.2
290
+
291
+ Fixes:
292
+ - 9.0.1 won't build with tsc when imported (thanks @mastermatt)
293
+
294
+ # 9.0.1
295
+
296
+ Fixes:
297
+ - Can't compile 9.0.0 version (thanks @Nihisil )
298
+
299
+ # 9.0.0
300
+
301
+ NOTE: This version is not compatible with previous templates (removed `route.request.params`, `apiConfig.props`, `apiConfig.generic`, `apiConfig.description`, `apiConfig.hasDescription`)
302
+
303
+ Fixes:
304
+ - Consider 2xx a successful status (thanks @wyozi)
305
+ - GET method query option bug (thanks @rhkdgns95, @SaschaGalley)
306
+ - `silent` property missed in `.d.ts` file (thanks @mastermatt)
307
+ - axios file upload `formData` type (thanks @guhyeon)
308
+ - make property `instance` to public in axios http client (It can be helpful in #226)
309
+ - variable name "params" doesn't uniq (thanks @mixalbl4-127 )
310
+
311
+ Features:
312
+ - `--disableProxy` option (thanks @kel666)
313
+ - `--extract-request-body` option. Allows to extract request body type to data contract
314
+ - Add TSDoc tag for deprecated route (thanks @wyozi)
315
+
316
+
317
+ # 8.0.3
318
+
319
+ - Fixes encoding array query params in `fetch` http templates (thanks @prog13)
320
+
321
+ # 8.0.2
322
+
323
+ Fixes:
324
+ - Wrong working the `format` option in `fetch` http client
325
+
326
+ # 8.0.1
327
+
328
+ Fixes:
329
+ - Not working `customFetch`
330
+ Error: `Failed to execute 'fetch' on 'Window': Illegal invocation`
331
+
332
+ # 8.0.0
333
+
334
+ BREAKING_CHANGES:
335
+ - remove default `json` format of the response type (both for `axios` and `fetch` http clients) (issue #213, thanks @po5i)
336
+
337
+ Features:
338
+ - Allow passing custom fetch function (`fetch` http client only)
339
+ - Allow to set global response type format through `HttpClient` constructor
340
+ Example:
341
+ ```ts
342
+ const httpClient = new HttpClient({ format: 'json' });
343
+ // all request responses will been formatted as json
344
+ ```
345
+ Fixes:
346
+ - Missing `schema.$ref` in inline enum schemas
347
+ - Array query param values are serialized with the (non-default) comma separated style (issue #222, thanks @Styn, PR #223)
348
+ - TypeScript error "TS6133: 'E' is declared but its value is never read." (`axios` http client) (issue #220, thanks @pmbednarczyk )
349
+
350
+ # 7.0.1
351
+
352
+ Fixes:
353
+ - "securityWorker" is only used if "secure" option is specified on each request (issue #212, thanks @dkamyshov)
354
+ NOTE: added global `secure` option for `axios` http client
355
+ - `index.d.ts` file (add `rawModelTypes`)
356
+
357
+ # 7.0.0
358
+
359
+ BREAKING_CHANGES:
360
+ - format `namespace` name in `--route-types` as camelCase with upper first capitalized letter
361
+ `foo_bar` -> `FooBar`
362
+
363
+ Fixes:
364
+ - Incorrect working the `--route-types` option with `--modular` option (route types should be splitted on files)
365
+ - Fix critical bug linked with enums with boolean type (thanks @haedaal)
366
+
367
+ Features:
368
+ - Ability to return `false` in `onCreateRoute` hook, it allow to ignore route
369
+ - Add output util functions
370
+ ```ts
371
+ createFile: (params: {
372
+ path: string;
373
+ fileName: string;
374
+ content: string;
375
+ withPrefix?: boolean;
376
+ }) => void;
377
+ renderTemplate: (
378
+ templateContent: string,
379
+ data: Record<string, unknown>,
380
+ etaOptions?: import("eta/dist/types/config").PartialConfig
381
+ ) => string;
382
+ getTemplate: (params: {
383
+ fileName?: string;
384
+ name?: string;
385
+ path?: string;
386
+ }) => string
387
+ formatTSContent: (content: string) => string;
388
+
389
+
390
+ // ...
391
+
392
+ generateApi({ /* ... */ }).then(({ createFile, renderTemplate, getTemplate }) => {
393
+ // do something
394
+ })
395
+ ```
396
+
397
+ # 6.4.2
398
+
399
+ Fixes:
400
+ - Bug with missing `name` property in in-path requests parameters
401
+ - Problem with usage `--route-types` with `--modular` option (mising import data contracts)
402
+
403
+ # 6.4.1
404
+
405
+ Fixes:
406
+ - Bug with axios headers (thanks @mutoe)
407
+
408
+ # 6.4.0
409
+
410
+ Features:
411
+ - `onFormatRouteName(routeInfo: RawRouteInfo, templateRouteName: string)` hook. Allows to format route name, as you like :)
412
+
413
+ Fixes:
414
+ - Bug with wrong complex types (anyOf, oneOf, allOf) when some child schema contains only description
415
+ ![example](./assets/changelog_assets/fixComplexTypeAny.jpg)
416
+ - Bug with number enums which have `x-enumNames`
417
+ - Problem with not existing `title` property in `info`
418
+
419
+ Minor:
420
+ - Improve description for complex types
421
+ - Improve description in single api file
422
+
423
+ # 6.3.0
424
+
425
+ Features:
426
+ - `--type-suffix` option. Allows to set suffix for data contract name. (issue #191, thanks @the-ult)
427
+ - `--type-prefix` option. Allows to set prefix for data contract name. (issue #191, thanks @the-ult)
428
+ Examples [here](./spec/typeSuffixPrefix/schema.ts)
429
+ - `onFormatTypeName(usageTypeName, rawTypeName)` hook. Allow to format data contract names as you want.
430
+
431
+ Internal:
432
+ - rename and split `checkAndRenameModelName` -> `formatModelName`, `fixModelName`
433
+
434
+ # 6.2.1
435
+
436
+ Fixes:
437
+ - missing `generateUnionEnums?: boolean;` in `index.d.ts` file (thanks @artsaban)
438
+ - missing default params to axios http client (`--axios`) (issue #192, thanks @Nihisil)
439
+
440
+ # 6.2.0
441
+
442
+ Features:
443
+ - `--module-name-first-tag` option. Splits routes based on the first tag (thanks @jnpoyser)
444
+
445
+ # 6.1.2
446
+
447
+ Fixes:
448
+ - Problems with using both `--axios` and `--modular` options together (TS, `organizeImports` crashed the codegeneration)
449
+
450
+ # 6.1.1
451
+
452
+ Fixes:
453
+ - Problems with `--axios` option
454
+ - ignoring `path`, `format`, `type` payload properties in `request()` method of `HttpClient`
455
+ - Missing `format` property for requests in `--modular` option
456
+
457
+ # 6.1.0
458
+
459
+ Features:
460
+ - `--silent` option. Output only errors to console (default: false)
461
+
462
+ Fixes:
463
+ - Bug with `kebab-case` path params (issue #184, thanks @Mr-sgreen)
464
+ - Typings for `--js` option
465
+
466
+ # 6.0.0
467
+
468
+ BREAKING_CHANGES:
469
+ - Ability to override only one template (issue #166, thanks @Nihisil)
470
+ - removed `TPromise` type for `--responses` options (perf. problem, issue #182, thanks @mixalbl4-127)
471
+ - breaking changes in `http-client.eta`
472
+ - `securityWorker` now can return `Promise<RequestParams | void> | RequestParams | void`
473
+
474
+ Features:
475
+ - template path prefixes `@base`, `@default`, `@modular` (using in Eta templates, `includeFile()`, see README.md)
476
+ - `--axios` option for axios http client (issue #142, thanks @msklvsk, @mixalbl4-127 )
477
+
478
+ # 5.1.7
479
+
480
+ Fixes:
481
+ - Do not fail if template file does not exist (issue #166, thanks @armsnyder )
482
+ Caveat: With this fix it will still error if the overridden template uses `includeFile` on a template file that is not overridden
483
+
484
+ # 5.1.6
485
+
486
+ Fixes:
487
+ - The contentFormatter for ContentType:Json does not correctly format strings (issue #176, thanks @Styn)
488
+
489
+ # 5.1.5
490
+
491
+ Fixes:
492
+ - ContentType.FormData no longer sets the correct boundary (issue #172, thanks @Styn)
493
+
494
+ # 5.1.4
495
+
496
+ Fixes:
497
+ - header overwrite in `default` and `modular` API templates (issue #171 by @Styn, thanks @emilecantin for PR with fix)
498
+
499
+ # 5.1.3
500
+
501
+ Fixes:
502
+ - Ignored `x-nullable` field
503
+ - Schema type names which starts with number or special characters
504
+
505
+ # 5.1.2
506
+
507
+ Fixes:
508
+ - Linter disable rules is not working (issue #164, thanks @Haritaso)
509
+
510
+ # 5.1.1
511
+
512
+ Fixes:
513
+ - The HttpResponse type is no longer exported from http-client (issue #161, thanks @Styn)
514
+
515
+ # 5.1.0
516
+
517
+ Fixes:
518
+ - Bug with optional nested properties of object schema type (issue #156, thanks @Fabiencdp)
519
+
520
+ Features:
521
+ - `onCreateRouteName(routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo): RouteNameInfo | void` hook
522
+ Which allows to customize route name without customizing `route-name.eta` template
523
+ - Improved content kinds for request infos
524
+ - `--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)
525
+
526
+ Minor:
527
+ - A bit improve type declaration file (index.d.ts) for this tool
528
+ - make exportable `ApiConfig` interface
529
+
530
+ Internal:
531
+ - clearing `routeNameDuplicatesMap` before each `parseRoutes()` function call
532
+ - Changed templates:
533
+ - `http-client.eta`
534
+ - `procedure-call.eta`
535
+ - `api.eta`
536
+
537
+ # 5.0.0
538
+
539
+ Fixes:
540
+ - Request content types auto substitution
541
+ i.e. if request body is form data, then request body content type will be `multipart/form-data`
542
+ - Strange method name (issue #152, thanks @RoXuS)
543
+ - Hardcoded Content-Type causes issues with some endpoints (issue #153, thanks @po5i)
544
+ - Critical bug with `:paramName` path params (issue #154)
545
+
546
+ Features:
547
+ - Ability to provide custom formatting `fetch` response
548
+ - `"IMAGE"` content kind for response\request data objects
549
+ - `RequestParams` `RequestHeaders` types for `--route-types` (`routeTypes: true`) option (issue #150, thanks @Fabiencdp )
550
+ - `--default-response` option. Allows to set default type for empty response schema (default: `void`) (based on issue #14)
551
+ - Request cancellation support (issue #96, thanks @ApacheEx)
552
+ `RequestParams` type now have the `cancelToken` field
553
+ `HttpClient` instance now have the `abortRequest(cancelToken)` method
554
+
555
+ BREAKING_CHANGES:
556
+ - Fully refactored `http-client.eta` template, make it more flexible and simpler.
557
+ `HttpClient["request"]` takes one argument with type `FullRequestParams`
558
+ (previously it takes many count of arguments which was not flexible)
559
+ - Changed the default response body type from `any` to `void` (issue #14)
560
+
561
+ Internal:
562
+ - Changed templates:
563
+ - `http-client.eta`
564
+ - `procedure-call.eta`
565
+ - `api.eta`
566
+
567
+ This version works with previous templates.
568
+
569
+ # 4.4.0
570
+
571
+ Fixes:
572
+ - Client generation for `Content-Type: application/x-www-form-urlencoded` (issue #146, thanks @Larox)
573
+
574
+ Internal:
575
+ - Changed templates:
576
+ - `http-client.eta`
577
+ - `procedure-call.eta`
578
+
579
+ # 4.3.0
580
+
581
+ Fixes:
582
+ - enum + nullable: true doesn't compute the good type (issue #145, thanks @RoXuS)
583
+ - Underscores are omitted from enum keys (issue #108, thanks @eolant)
584
+ - CLI silently fails if the directory to put new files in doesn't exist yet (issue #141, thanks @Styn)
585
+
586
+ Features:
587
+ - Improved type description
588
+
589
+ Internal:
590
+ - dependencies update:
591
+ - `"js-yaml": "^4.0.0"` (`"^3.14.1"`)
592
+ - `"make-dir": "^3.1.0"`
593
+ - `"swagger2openapi": "^7.0.5"` (`"^7.0.4"`)
594
+ - Difference in templates:
595
+ - `data-contracts.eta`
596
+ ![dataContracts430](./assets/changelog_assets/http-client-template-diff-4.3.0.jpg)
597
+
598
+ # 4.2.0
599
+ Features:
600
+ - new hook `onCreateRequestParams` which allows modify request params (`--extract-request-params` option) before sending it to route info
601
+ ![onCreateRequestParams](./assets/changelog_assets/onCreateRequestParamsHook.jpg)
602
+ How to use:
603
+ ```ts
604
+ generateApi({
605
+ // ... your config,
606
+ hooks: {
607
+ onCreateRequestParams: (rawType) => {
608
+ if (Object.keys(rawType.properties).length > 1) return rawType;
609
+
610
+ return rawType;
611
+ }
612
+ }
613
+ })
614
+ ```
615
+ - response content types (array of string like `application/json`, `image/png`) which allows to customize declaration of request response
616
+ Exist in `procedure-call.eta` template `it.route.response.contentTypes`
617
+
618
+ Internal:
619
+ - Difference in templates:
620
+ - `procedure-call.eta`
621
+ ![procedureCallEta1](./assets/changelog_assets/changes_procedure_call_1.jpg)
622
+
623
+
624
+ # 4.1.0
625
+
626
+ Features:
627
+ - Improve `require()` function used in ETA templates (using relative path imports)
628
+ - `--clean-output` option.
629
+ clean output folder before generate api
630
+
631
+ Fixes:
632
+ - Error: `Unexpected token =` (Issue #136, Thanks @jlow-mudbath)
633
+ - Output folder creation (Issue #137, Thanks @Rinta01)
634
+ Create output folder if it is not exist
635
+
636
+ # 4.0.5
637
+
638
+ BREAKING_CHANGE:
639
+ - remove `'prettier-plugin-organize-imports'` dependency from package
640
+
641
+ Fixes:
642
+ - issue #134 (Thanks @mrfratello)
643
+
644
+ # 4.0.4
645
+
646
+ Features:
647
+ - add `require()` to template `utils` object
648
+
649
+ Docs:
650
+ - add information about contributors
651
+
652
+ # 4.0.3
653
+
654
+ Features:
655
+ - `--disableStrictSSL` option for disable strict SSL statement with fetching swagger schema. (Thanks @kel666 for PR with feature request)
656
+ This option fix problem #114
657
+
658
+ # 4.0.2
659
+
660
+ Fixes:
661
+ - `Unexpected token '.'` on v4 (Thanks @savingprivatebryan for issue #111)
662
+ Replaced all new syntax sugar like `?.` or `??` to prev. alternatives for support nodejs 12
663
+
664
+ # 4.0.1
665
+
666
+ Fixes:
667
+ - `Cannot find module 'prettier-plugin-organize-imports'` #109
668
+
669
+ # 4.0.0
670
+
671
+ BREAKING_CHANGES:
672
+ - Migrate from [mustache](https://mustache.github.io/) template engine to [ETA](https://eta.js.org/) template engine. (Thanks @Fl0pZz)
673
+ - Critical change in `HttpResponse` type (Remove `D | null`, `E | null` unions)
674
+ ```diff
675
+ interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
676
+ - data: D | null;
677
+ + data: D;
678
+ - error: E | null;
679
+ + error: E;
680
+ }
681
+ ```
682
+
683
+ Features:
684
+ - `--modular` option. Allows to generate api class per module name.
685
+ Example: [here](./tests/spec/modular)
686
+ - new templates on [ETA](https://eta.js.org/) (enhanced EJS) which can improve your templates! (Thanks @Fl0pZz)
687
+ [ETA extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=shadowtime2000.eta-vscode) (thanks @shadowtime2000)
688
+ Also moved out to templates:
689
+ - `procedure-call.eta` (request api method template)
690
+ - `route-name.eta` (api method name template)
691
+ - `route-docs.eta` (api method docs template)
692
+
693
+ No worry about strange syntax it is very simple in usage :)
694
+ - Optional templates feature (Except templates using in `includeFile` `ETA` directive)
695
+ Now you can store only the `ETA` templates which you need to change for yourself.
696
+ - `--extract-request-params` option. Generate path and query request params data contract and modify request payload args
697
+ Example:
698
+ ![extract-request-params](./assets/changelog_assets/extractRequestParams.jpg)
699
+ - Improve `data-contracts.eta` template. Added more power :)
700
+ - Add `extraTemplates` property for `generateApi()`. Allows to generate extra files via this tool.
701
+ - Add `hooks` property for `generateApi()`
702
+ ```ts
703
+ hooks?: Partial<{
704
+ onCreateComponent: (component: SchemaComponent) => SchemaComponent | void;
705
+ onParseSchema: (originalSchema: any, parsedSchema: any) => any | void;
706
+ onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | void;
707
+ /** Start point of work this tool (after fetching schema) */
708
+ onInit?: <C extends GenerateApiConfiguration["config"]>(configuration: C) => C | void;
709
+ /** Allows to customize configuration object before sending it to templates. */
710
+ onPrepareConfig?: <C extends GenerateApiConfiguration>(currentConfiguration: C) => C | void;
711
+ }>;
712
+ ```
713
+ ```ts
714
+ generateApi({
715
+ input: "./schema.json",
716
+ output: "./__generated__",
717
+ hooks: {
718
+ onCreateComponent(component) {
719
+ // do something
720
+ return component;
721
+ },
722
+ // ...
723
+ }
724
+ })
725
+ ```
726
+
727
+ Internal:
728
+ - Update all dependencies to latest
729
+
730
+ Fixes:
731
+ - `x-enumNames` support for enums
732
+ - Problem of complex types (`oneOf`, `allOf`) with `properties` field
733
+ - `additionalProperties: true` should make `[key: string]: any` for object types (Thanks @brookjordan for issue #103)
734
+
735
+ Common:
736
+ - `HttpClient` is exportable by default
737
+ - Improve typings when use `swagger-typescript-api` with NodeJS (`index.d.ts`)
738
+
739
+ # 3.1.2
740
+ Fixes:
741
+ - axios vulnerability (#101 issue, thanks @Mvbraathen)
742
+
743
+ # 3.1.1
744
+
745
+ Fixes:
746
+ - `name.includes is not a function` (issue #98)
747
+
748
+ # 3.1.0
749
+
750
+ Features:
751
+ - `--moduleNameIndex` option. determines which path index should be used for routes separation (Thanks @nikalun)
752
+ Examples:
753
+ GET:api/v1/fruites/getFruit -> index:2 -> moduleName -> fruites
754
+ GET:api/v1/fruites/getFruit -> index:0 -> moduleName -> api
755
+
756
+ # 3.0.1
757
+
758
+ Fixes:
759
+ - invalid default templates path (#92, thanks @larrybotha for quick fix)
760
+
761
+ # 3.0.0
762
+
763
+ BREAKING_CHANGES:
764
+ - Renamed mustache templates:
765
+ - `api.mustache` -> `data-contracts.mustache`
766
+ - `client.mustache` -> `http.client.mustache` + `api.mustache`
767
+ - Split the `client.mustache` template into two parts: `http-client.mustache` and `api.mustache`
768
+
769
+ Fixes:
770
+ - Fixed unsafe clone() of Response causing json() hang. (Thanks @Benjamin-Dobell)
771
+
772
+ # 2.0.0
773
+
774
+ Features:
775
+ - `--js` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/79)
776
+
777
+ BREAKING_CHANGES:
778
+ - Requests returns `Promise<HttpResponse<Data, Error>>` type.
779
+ `HttpResponse` it is [Fetch.Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) wrapper with fields `data` and `error`
780
+ Example:
781
+ ```ts
782
+ const api = new Api()
783
+
784
+ //
785
+ const response: HttpResponse<Data, Error> = await api.fruits.getAll()
786
+
787
+ response.data // Data (can be null if response.ok is false)
788
+ response.error // Error (can be null if response.ok is true)
789
+ ```
790
+ - Breaking changes in the `client.mustache` template. Needs to update local custom templates.
791
+
792
+ Fixes:
793
+ - Security configuration in methods. When the security definition is in the main configuration of the swagger definition
794
+
795
+
796
+ # 1.12.0
797
+
798
+ Features:
799
+ - Can provide ability to generate from swagger JSON directly not from a file? #69 (Thanks @JennieJi)
800
+
801
+ Fixes:
802
+ - handling `x-omitempty` property for definition properties #68
803
+ - Additional properties map to empty interfaces (OpenAPI v3) #76
804
+ - Pattern fields in Path Item Object are treated as operations #75
805
+ - Remove const enum from default template #73
806
+ - enums with spaces throw an error #71
807
+
808
+
809
+ # 1.11.0
810
+
811
+ Features:
812
+ - Improve the naming of model types ([#65 issue](https://github.com/acacode/swagger-typescript-api/issues/65))
813
+
814
+ # 1.10.0
815
+
816
+ Features:
817
+ - `--templates` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/54)
818
+ Provide custom `mustache` templates folder which allows to generate custom code (models, Api class, routes)
819
+ - `--union-enums` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/58)
820
+ Allows to generate all enums as union types.
821
+ For example, schema part:
822
+ ```
823
+ "StringEnum": {
824
+ "enum": ["String1", "String2", "String3", "String4"],
825
+ "type": "string"
826
+ }
827
+ ```
828
+ will be converted into:
829
+ ```
830
+ export type StringEnum = "String1" | "String2" | "String3" | "String4";
831
+ ```
832
+
833
+
834
+ # 1.8.4
835
+
836
+ Fixes:
837
+ - Multiple types for a property in Swagger 2 are not handled correctly ([#55 issue](https://github.com/acacode/swagger-typescript-api/issues/55))
838
+
839
+ # 1.8.3
840
+
841
+ Fixes:
842
+ - Generating invalid code in composed schema contexts ([#51 issue](https://github.com/acacode/swagger-typescript-api/issues/51))
843
+ ```yaml
844
+ components:
845
+ schemas:
846
+ Test:
847
+ type: object
848
+ allOf:
849
+ - type: object
850
+ properties:
851
+ x:
852
+ type: array
853
+ items:
854
+ type: string
855
+ enum:
856
+ - A-B
857
+ - type: object
858
+ properties:
859
+ y:
860
+ type: string
861
+ ```
862
+ ```ts
863
+ export type Test = XAB & { y?: string };
864
+ ```
865
+
866
+ # 1.8.2
867
+
868
+ Fixes:
869
+ - Broken types for arrays of union types ([issue](https://github.com/acacode/swagger-typescript-api/issues/49))
870
+
871
+ # 1.8.1
872
+
873
+ Fixes:
874
+ - form data request body (request body content `multipart/form-data`)
875
+
876
+ Minor:
877
+ - inline comments of the data contract type properties
878
+ ![one line comments](./assets/changelog_assets/one-line-comments.jpg)
879
+ - remove `Array<T>` type usage (now the more simple type `T[]`)
880
+
881
+ # 1.8.0
882
+
883
+ Features:
884
+
885
+ - **Partially** support FormData body types
886
+ - Support to generate query params of nested query objects (Partial fix of [this issue](https://github.com/acacode/swagger-typescript-api/issues/45))
887
+
888
+
889
+ # 1.7.2
890
+
891
+ Fixes:
892
+
893
+ - Critical bug with converting inline object into name of type for request body.
894
+ - Fix bug when path parameters is not set but contains in endpoint url.
895
+ ![path params bug 1](./assets/changelog_assets/bug-with-no-path-args.jpg)
896
+ ![path params bug 2](./assets/changelog_assets/bug-with-no-path-args2.jpg)
897
+
898
+
899
+ # 1.7.0
900
+
901
+ Breaking Changes:
902
+
903
+ - 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))
904
+ ![removed title and version properties](./assets/changelog_assets/removed-title-version-props.jpg)
905
+ - Move out all http client handlers/properties into `HttpClient` local class in module
906
+ ![http-client-class1](./assets/changelog_assets/http-client-class1.jpg)
907
+ ![http-client-class2](./assets/changelog_assets/http-client-class2.jpg)
908
+
909
+ Chore:
910
+
911
+ - default value for `SecurityDataType` Api class generic type
912
+
913
+
914
+ # 1.6.3
915
+
916
+ Fixes:
917
+
918
+ - Handling of nullable for $ref in OpenAPI 3.0 ([issue](https://github.com/acacode/swagger-typescript-api/issues/39))
919
+ Plus based on this issue was fixed most other problems with using `required` and `nullable` properties
920
+
921
+
922
+ # 1.6.2
923
+
924
+ Fixes:
925
+
926
+ - Nullable not included in type definition ([issue](https://github.com/acacode/swagger-typescript-api/issues/36))
927
+
928
+ Internal:
929
+
930
+ - Update `swagger2openapi`(`6.0.0`) dependency
931
+
932
+ # 1.6.1
933
+
934
+ Internal:
935
+
936
+ - Update `prettier`(`2.0.2`), `swagger2openapi`(`5.4.0`) dependencies
937
+
938
+ # 1.6.0
939
+
940
+ Features:
941
+
942
+ - Improvenment in optional request params (request body, query params, path params)
943
+
944
+ Fixes:
945
+
946
+ - Fix bug when `path` request param have the same name as `query`
947
+ - Fix bug when `path` request param have the same name as `params`
948
+
949
+ Minor/Internal:
950
+
951
+ - changed `addQueryParams()` method
952
+ - up `swagger2openapi` dependency version to `5.3.4`
953
+
954
+ # 1.5.0
955
+
956
+ Features:
957
+
958
+ - Add `prettier` for beautify output typescript api module
959
+ - Support `additionalProperties` type data
960
+ ![additional properties](./assets/changelog_assets/additional-properties-types.jpg)
961
+
962
+ Fixes:
963
+
964
+ - Fix problem with array `type` definitions without `type` property([#26](https://github.com/acacode/swagger-typescript-api/issues/26))
965
+
966
+ # 1.4.1
967
+
968
+ Fixes:
969
+
970
+ - 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))
971
+
972
+ # 1.4.0
973
+
974
+ Breaking Changes:
975
+
976
+ - Rename default typescript output api file name (prev `api.ts`, now `Api.ts`)
977
+ Features:
978
+ - `-d, --default-as-success` option. Allows to use "default" status codes as success response type
979
+ - `-r, --responses` option. Response declarations in request rescription
980
+ This option adds comments of the possible responses from request
981
+ ![responses comments](./assets/changelog_assets/responses-comments.jpg)
982
+ Also typings for `.catch()` callback
983
+ ![responses catch types](./assets/changelog_assets/responses-catch-types.jpg)
984
+ - Improve response body type definitions
985
+ - Types for bad responses
986
+ Changes:
987
+ - \[minor\] fix jsdoc comments space
988
+ ![right comments space](./assets/changelog_assets/right-comments-space.jpg)
989
+
990
+ # 1.3.0
991
+
992
+ Features:
993
+
994
+ - Api module description from schema info
995
+ ![api description](./assets/changelog_assets/api-module-description.jpg)
996
+ - Generate API type declarations (CLI flag `--route-types`, thanks [azz](https://github.com/azz))
997
+ ![route types](./assets/changelog_assets/route-types.jpg)
998
+ - Ability to not generate clint API class (CLI flag `--no-client`, thanks [azz](https://github.com/azz))
999
+
1000
+ Fixes:
1001
+
1002
+ - Improve response body type definition
1003
+
1004
+ Internal:
1005
+
1006
+ - refactored `generate` and `validate` test scripts
1007
+
1008
+ # 1.2.6
1009
+
1010
+ Fixes: create api without `-o` option (use default `./` output)
1011
+
1012
+ # 1.2.5
1013
+
1014
+ Features: better naming of routes without `operationId`
1015
+ ![route naming](./assets/changelog_assets/1.2.5_route_naming.jpg)
1016
+ Changes: rename `@security true` -> `@secure`, `@duplicate true` -> `@duplicate`
1017
+ Fixes: Support generated swagger schemes from tsoa 3.x with complex types (Omit, Pick, etc)
1018
+
1019
+ # 1.2.4
1020
+
1021
+ Features: add .d.ts file into npm package
1022
+ Changes: update help block in CLI
1023
+ Internal: add greenkeeper, update npm keywords
1024
+
1025
+ # 1.2.3
1026
+
1027
+ Features: @summary, @description comments at each route
1028
+ Fixes: parsing schema without routes
1029
+ Changes: update documentation
1030
+ Internal: add anyOf, allOf test schemas, slack notifications in CI
1031
+
1032
+ # 1.2.2
1033
+
1034
+ Fixes: fix complex types (oneOf, anyOf), required fields of object type was not required
1035
+
1036
+ # 1.2.0
1037
+
1038
+ Changes: rename `ApiParams` to `RequestParams`, secure module always exist in generated API module, update documentation
1039
+ Fixes: Query params was all required, parse yaml files, typescript minor warnings (;)
1040
+ Internal: test schemas + manual testing, add travis CI/CD
1041
+
1042
+ # 1.1.0
1043
+
1044
+ Fixes: catching http errors with use API module
1045
+
1046
+ # 1.0.9
1047
+
1048
+ Features: add description to interfaces and their fields
1049
+ Changes: update documentation
1050
+
1051
+ # 1.0.8
1052
+
1053
+ Changes: update documentation
1054
+
1055
+ # 1.0.7
1056
+
1057
+ Changes: update documentation (+ add logo), add comment about author in generated module
1058
+
1059
+ # 1.0.6
1060
+
1061
+ Fixes: route naming, http(s) requests for getting swagger schema, integer enums
1062
+ Changes: include only required files into npm pacakge
1063
+
1064
+ # 1.0.5
1065
+
1066
+ Changes: update documentation
1067
+
1068
+ # 1.0.4
1069
+
1070
+ Changes: disable linters rules for generated API module
1071
+ Fixes: TS issues in template
1072
+
1073
+ # 1.0.3
1074
+
1075
+ Fixes: NodeJS main script cannot been called on Unix\* machines
1076
+ Changes: add LICENSE, update README
1077
+
1078
+ # 1.0.2
1079
+
1080
+ Changes(Internal): change dependencies
1081
+
1082
+ # 1.0.1
1083
+
1084
+ New features: query params, separating routes on submodules, common params in constructor, swagger v2 + yaml parsers
1085
+ Enhancements: better type extracting.
1086
+ Fixes: mustache escaping chars
1087
+ Changes: order of request params, emojis messages in console
1088
+
1089
+ # 1.0.0
1090
+
1091
+ Initial project.