swagger-typescript-api 11.1.3 → 12.0.0

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