dtsgenerator 3.18.0 → 3.19.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 +157 -2
- package/README.md +6 -154
- package/dist/core/dtsGenerator.js +4 -5
- package/dist/core/openApiV3.d.ts +2 -2
- package/dist/core/schemaId.js +1 -1
- package/dist/core/type.js +1 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +15 -20
- package/package.json +19 -18
- package/src/cli.ts +3 -3
- package/src/commandOptions.ts +4 -4
- package/src/core/astBuilder.ts +28 -28
- package/src/core/config.ts +1 -1
- package/src/core/dtsGenerator.ts +63 -63
- package/src/core/jsonSchema.ts +37 -37
- package/src/core/openApiV2.ts +2 -2
- package/src/core/openApiV3.ts +1 -8
- package/src/core/referenceResolver.ts +9 -9
- package/src/core/schemaId.ts +4 -1
- package/src/core/type.ts +9 -9
- package/src/core/utils.ts +3 -3
- package/src/core/validateIdentifier.ts +2 -1
- package/src/jsonPointer.ts +1 -1
- package/src/utils.ts +23 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,161 @@
|
|
|
1
1
|
# ChangeLog
|
|
2
2
|
|
|
3
|
+
## v3
|
|
4
|
+
|
|
5
|
+
### [v3.15.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.15.1) (2022-03-10)
|
|
6
|
+
|
|
7
|
+
- fixed:
|
|
8
|
+
- Fix handling of stdin option with config file for #534. Thank you @arnestaphorsius :+1:
|
|
9
|
+
|
|
10
|
+
### [v3.15.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.15.0) (2022-02-06)
|
|
11
|
+
|
|
12
|
+
- features:
|
|
13
|
+
- Support mobile wallet media types(`application/jwt` and `application/vnd.apple.pkpass`) for #530. Thank you @eostrom :+1:
|
|
14
|
+
|
|
15
|
+
### [v3.14.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.14.0) (2022-01-27)
|
|
16
|
+
|
|
17
|
+
- features:
|
|
18
|
+
- Support the nested `allOf` and `oneOf` schema for #513. Thank you for your report @Cry0nicS :+1:
|
|
19
|
+
|
|
20
|
+
### [v3.13.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.2) (2021-10-08)
|
|
21
|
+
|
|
22
|
+
- features:
|
|
23
|
+
- Fix the type generation malformed objects with number-like keys for #523. Thank you for your report @DamianOsipiuk :+1:
|
|
24
|
+
|
|
25
|
+
### [v3.13.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.1) (2021-09-29)
|
|
26
|
+
|
|
27
|
+
- features:
|
|
28
|
+
- Change the plug-in interface, the PluginContext::inputSchemas to IterableIterator for #521. Thank you @djrollins :+1:
|
|
29
|
+
|
|
30
|
+
### [v3.13.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.0) (2021-08-31)
|
|
31
|
+
|
|
32
|
+
- features:
|
|
33
|
+
- Support new `$schema` types for #507.
|
|
34
|
+
|
|
35
|
+
### [v3.12.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.12.1) (2021-05-19)
|
|
36
|
+
|
|
37
|
+
- fixed:
|
|
38
|
+
- Fix referenced parameters not resolved error by #471. Thank you @jschirrmacher :+1:
|
|
39
|
+
|
|
40
|
+
### [v3.12.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.12.0) (2021-05-13)
|
|
41
|
+
|
|
42
|
+
- features:
|
|
43
|
+
- Support input type `file` by #496. Thank you @Christian24 :+1:
|
|
44
|
+
- Improve the conversion results of parameters property on OpenAPI by #501.
|
|
45
|
+
|
|
46
|
+
### [v3.11.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.11.0) (2021-05-11)
|
|
47
|
+
|
|
48
|
+
- features:
|
|
49
|
+
- Support vendor media types (allow periods in application/*+json) by #497. Thank you @glen-84 :+1:
|
|
50
|
+
- fixed:
|
|
51
|
+
- Remove to support the `readOnly` property, because of wrong interpretation by #498. Thank you @hallsbyra :+1:
|
|
52
|
+
|
|
53
|
+
### [v3.10.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.10.0) (2021-04-26)
|
|
54
|
+
|
|
55
|
+
- features:
|
|
56
|
+
- Support freeform objects w/ index signature instead of `unknown` keyword by #488. Thank you @medfreeman :+1:
|
|
57
|
+
- Support the `content` property in `Parameters` by #472. Thank you for report @npdev453 :+1:
|
|
58
|
+
|
|
59
|
+
### [v3.9.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.9.2) (2021-04-19)
|
|
60
|
+
|
|
61
|
+
- fixed:
|
|
62
|
+
- Fix nested `oneOf` & `anyOf` keywords by #486. Thank you @medfreeman :+1:
|
|
63
|
+
|
|
64
|
+
### [v3.9.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.9.1) (2021-04-16)
|
|
65
|
+
|
|
66
|
+
- fixed:
|
|
67
|
+
- Update `generate` function to use recommended immutable approach for typescript transforms by #483. Thank you again @medfreeman :+1:
|
|
68
|
+
|
|
69
|
+
### [v3.9.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.9.0) (2021-04-13)
|
|
70
|
+
|
|
71
|
+
- features:
|
|
72
|
+
- support for additionalItems property by #481. Thank you again @medfreeman :+1:
|
|
73
|
+
|
|
74
|
+
### [v3.8.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.8.0) (2021-04-08)
|
|
75
|
+
|
|
76
|
+
- features:
|
|
77
|
+
- full support for minItems & maxItems properties by #476. Thank you @medfreeman :+1:
|
|
78
|
+
|
|
79
|
+
### [v3.7.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.7.1) (2021-02-18)
|
|
80
|
+
|
|
81
|
+
- fixed:
|
|
82
|
+
- add truthy check for value in `mergeSchema` by #474. Thank you @ricokahler :+1:
|
|
83
|
+
|
|
84
|
+
### [v3.7.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.7.0) (2021-01-05)
|
|
85
|
+
|
|
86
|
+
- features:
|
|
87
|
+
- Add the `void` type support by #468. Thank you for your propose @henhal by #445 :+1:
|
|
88
|
+
|
|
89
|
+
### [v3.6.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.6.0) (2020-12-25)
|
|
90
|
+
|
|
91
|
+
- features:
|
|
92
|
+
- Improve the type result of oneOf/anyOf property by #467. Thank you for your report @crizo23 by #452 :+1:
|
|
93
|
+
- Improve the internal eslint configuration by #466. Thank you @Goldziher :+1:
|
|
94
|
+
|
|
95
|
+
### [v3.5.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.5.0) (2020-12-21)
|
|
96
|
+
|
|
97
|
+
- features:
|
|
98
|
+
- Add to export `ts` object for to use the same version TypeScript in all plugins by #465.
|
|
99
|
+
|
|
100
|
+
### [v3.4.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.4.1) (2020-12-16)
|
|
101
|
+
|
|
102
|
+
- fixed:
|
|
103
|
+
- Fix using package without esModuleInterop setting on tsconfig by #460. Thank you @wszydlak :+1:
|
|
104
|
+
- Update TypeScript v4 by #462. Thank you @wszydlak :+1:
|
|
105
|
+
- Add to support the null type enum value by #464. Thank you for your report @Goldziher :+1:
|
|
106
|
+
|
|
107
|
+
### [v3.4.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.4.0) (2020-12-15)
|
|
108
|
+
|
|
109
|
+
- features:
|
|
110
|
+
- Add support for multipart media type by #455. Thank you @wszydlak :+1:
|
|
111
|
+
- Add support for passing config object with NodeJS API usage by #456. Thank you @wszydlak :+1:
|
|
112
|
+
|
|
113
|
+
### [v3.3.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.3.1) (2020-10-05)
|
|
114
|
+
|
|
115
|
+
- fixed:
|
|
116
|
+
- Elements get type "any" instead of the correct one by #448. Thank you for your report @nachtigall-83 :+1:
|
|
117
|
+
|
|
118
|
+
### [v3.3.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.3.0) (2020-07-29)
|
|
119
|
+
|
|
120
|
+
- features:
|
|
121
|
+
- Support the `patternProperties` by #436. Thank you @nfroidure :+1:
|
|
122
|
+
- fixed:
|
|
123
|
+
- Definition generated improperly when multiple instances of a resource are inherited by #279. Thank you @btg5679 :+1:
|
|
124
|
+
- Apply the `prettier` config on `.eslintrc.json`.
|
|
125
|
+
|
|
126
|
+
### [v3.2.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.2.0) (2020-07-20)
|
|
127
|
+
|
|
128
|
+
- features:
|
|
129
|
+
- Add support for application/octet-stream media type by #431. Thank you @MisterChateau :+1:
|
|
130
|
+
|
|
131
|
+
### [v3.1.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.1.1) (2020-06-23)
|
|
132
|
+
|
|
133
|
+
- fixed:
|
|
134
|
+
- Cannot load config file of relative path by #428. Thank you @DamianOsipiuk :+1:
|
|
135
|
+
|
|
136
|
+
### [v3.1.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.1.0) (2020-06-22)
|
|
137
|
+
|
|
138
|
+
- features:
|
|
139
|
+
- Add support for nullable anyOf in OpenApi v3 by #426. Thank you @joost-kersjes-webpower :+1:
|
|
140
|
+
|
|
141
|
+
### [v3.0.3](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.0.3) (2020-06-15)
|
|
142
|
+
|
|
143
|
+
- fixed:
|
|
144
|
+
- Fix the command option example by #422. Thank you @maapteh :+1:
|
|
145
|
+
- Omit load config error on not config option by #425. Thank you @Christian24 :+1:
|
|
146
|
+
|
|
147
|
+
### [v3.0.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.0.2) (2020-06-11)
|
|
148
|
+
|
|
149
|
+
- fixed:
|
|
150
|
+
- Remove old example by #421. Thank you @maapteh :+1:
|
|
151
|
+
|
|
152
|
+
### [v3.0.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.0.1) (2020-06-09)
|
|
153
|
+
|
|
154
|
+
- features:
|
|
155
|
+
- Support the plug-in for pre-process and post-process.
|
|
156
|
+
- Change command line options and Support config file.
|
|
157
|
+
- Use the TypeScript AST for intermediate format.
|
|
158
|
+
|
|
3
159
|
## v2
|
|
4
160
|
|
|
5
161
|
### [v2.7.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v2.7.0) (2020-06-05)
|
|
@@ -82,7 +238,7 @@
|
|
|
82
238
|
|
|
83
239
|
- features
|
|
84
240
|
- Add to support the `nullable` property on OpenAPI by #319. Thank you @sakari :+1:
|
|
85
|
-
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types
|
|
241
|
+
<https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types>
|
|
86
242
|
|
|
87
243
|
### [v2.0.4](https://github.com/horiuchi/dtsgenerator/releases/tag/v2.0.4) (2019-01-07)
|
|
88
244
|
|
|
@@ -100,7 +256,6 @@
|
|
|
100
256
|
- features
|
|
101
257
|
- Add to support emit the Request/Response object schema of OpenAPI by #304.
|
|
102
258
|
|
|
103
|
-
|
|
104
259
|
## v1
|
|
105
260
|
|
|
106
261
|
### [v1.2.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v1.2.0) (2018-09-12)
|
package/README.md
CHANGED
|
@@ -143,6 +143,12 @@ Output debug message by [debug](https://www.npmjs.com/package/debug) library.
|
|
|
143
143
|
|
|
144
144
|
## ChangeLog
|
|
145
145
|
|
|
146
|
+
### [v3.19.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.19.1) (2023-08-25)
|
|
147
|
+
|
|
148
|
+
- features:
|
|
149
|
+
- Update plugins for new TypeScript AST.
|
|
150
|
+
- Changed supported Node.js version to 16 or later. Also, we have confirmed that it works with Node.js v20.
|
|
151
|
+
|
|
146
152
|
### [v3.18.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.18.0) (2023-03-02)
|
|
147
153
|
|
|
148
154
|
- features:
|
|
@@ -163,160 +169,6 @@ Output debug message by [debug](https://www.npmjs.com/package/debug) library.
|
|
|
163
169
|
- features:
|
|
164
170
|
- Support 'image/*' media types for #539. Thank you @Geloosa :+1:
|
|
165
171
|
|
|
166
|
-
### [v3.15.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.15.1) (2022-03-10)
|
|
167
|
-
|
|
168
|
-
- fixed:
|
|
169
|
-
- Fix handling of stdin option with config file for #534. Thank you @arnestaphorsius :+1:
|
|
170
|
-
|
|
171
|
-
### [v3.15.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.15.0) (2022-02-06)
|
|
172
|
-
|
|
173
|
-
- features:
|
|
174
|
-
- Support mobile wallet media types(`application/jwt` and `application/vnd.apple.pkpass`) for #530. Thank you @eostrom :+1:
|
|
175
|
-
|
|
176
|
-
### [v3.14.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.14.0) (2022-01-27)
|
|
177
|
-
|
|
178
|
-
- features:
|
|
179
|
-
- Support the nested `allOf` and `oneOf` schema for #513. Thank you for your report @Cry0nicS :+1:
|
|
180
|
-
|
|
181
|
-
### [v3.13.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.2) (2021-10-08)
|
|
182
|
-
|
|
183
|
-
- features:
|
|
184
|
-
- Fix the type generation malformed objects with number-like keys for #523. Thank you for your report @DamianOsipiuk :+1:
|
|
185
|
-
|
|
186
|
-
### [v3.13.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.1) (2021-09-29)
|
|
187
|
-
|
|
188
|
-
- features:
|
|
189
|
-
- Change the plug-in interface, the PluginContext::inputSchemas to IterableIterator for #521. Thank you @djrollins :+1:
|
|
190
|
-
|
|
191
|
-
### [v3.13.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.13.0) (2021-08-31)
|
|
192
|
-
|
|
193
|
-
- features:
|
|
194
|
-
- Support new `$schema` types for #507.
|
|
195
|
-
|
|
196
|
-
### [v3.12.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.12.1) (2021-05-19)
|
|
197
|
-
|
|
198
|
-
- fixed:
|
|
199
|
-
- Fix referenced parameters not resolved error by #471. Thank you @jschirrmacher :+1:
|
|
200
|
-
|
|
201
|
-
### [v3.12.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.12.0) (2021-05-13)
|
|
202
|
-
|
|
203
|
-
- features:
|
|
204
|
-
- Support input type `file` by #496. Thank you @Christian24 :+1:
|
|
205
|
-
- Improve the conversion results of parameters property on OpenAPI by #501.
|
|
206
|
-
|
|
207
|
-
### [v3.11.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.11.0) (2021-05-11)
|
|
208
|
-
|
|
209
|
-
- features:
|
|
210
|
-
- Support vendor media types (allow periods in application/*+json) by #497. Thank you @glen-84 :+1:
|
|
211
|
-
- fixed:
|
|
212
|
-
- Remove to support the `readOnly` property, because of wrong interpretation by #498. Thank you @hallsbyra :+1:
|
|
213
|
-
|
|
214
|
-
### [v3.10.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.10.0) (2021-04-26)
|
|
215
|
-
|
|
216
|
-
- features:
|
|
217
|
-
- Support freeform objects w/ index signature instead of `unknown` keyword by #488. Thank you @medfreeman :+1:
|
|
218
|
-
- Support the `content` property in `Parameters` by #472. Thank you for report @npdev453 :+1:
|
|
219
|
-
|
|
220
|
-
### [v3.9.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.9.2) (2021-04-19)
|
|
221
|
-
|
|
222
|
-
- fixed:
|
|
223
|
-
- Fix nested `oneOf` & `anyOf` keywords by #486. Thank you @medfreeman :+1:
|
|
224
|
-
|
|
225
|
-
### [v3.9.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.9.1) (2021-04-16)
|
|
226
|
-
|
|
227
|
-
- fixed:
|
|
228
|
-
- Update `generate` function to use recommended immutable approach for typescript transforms by #483. Thank you again @medfreeman :+1:
|
|
229
|
-
|
|
230
|
-
### [v3.9.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.9.0) (2021-04-13)
|
|
231
|
-
|
|
232
|
-
- features:
|
|
233
|
-
- support for additionalItems property by #481. Thank you again @medfreeman :+1:
|
|
234
|
-
|
|
235
|
-
### [v3.8.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.8.0) (2021-04-08)
|
|
236
|
-
|
|
237
|
-
- features:
|
|
238
|
-
- full support for minItems & maxItems properties by #476. Thank you @medfreeman :+1:
|
|
239
|
-
|
|
240
|
-
### [v3.7.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.7.1) (2021-02-18)
|
|
241
|
-
|
|
242
|
-
- fixed:
|
|
243
|
-
- add truthy check for value in `mergeSchema` by #474. Thank you @ricokahler :+1:
|
|
244
|
-
|
|
245
|
-
### [v3.7.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.7.0) (2021-01-05)
|
|
246
|
-
|
|
247
|
-
- features:
|
|
248
|
-
- Add the `void` type support by #468. Thank you for your propose @henhal by #445 :+1:
|
|
249
|
-
|
|
250
|
-
### [v3.6.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.6.0) (2020-12-25)
|
|
251
|
-
|
|
252
|
-
- features:
|
|
253
|
-
- Improve the type result of oneOf/anyOf property by #467. Thank you for your report @crizo23 by #452 :+1:
|
|
254
|
-
- Improve the internal eslint configuration by #466. Thank you @Goldziher :+1:
|
|
255
|
-
|
|
256
|
-
### [v3.5.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.5.0) (2020-12-21)
|
|
257
|
-
|
|
258
|
-
- features:
|
|
259
|
-
- Add to export `ts` object for to use the same version TypeScript in all plugins by #465.
|
|
260
|
-
|
|
261
|
-
### [v3.4.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.4.1) (2020-12-16)
|
|
262
|
-
|
|
263
|
-
- fixed:
|
|
264
|
-
- Fix using package without esModuleInterop setting on tsconfig by #460. Thank you @wszydlak :+1:
|
|
265
|
-
- Update TypeScript v4 by #462. Thank you @wszydlak :+1:
|
|
266
|
-
- Add to support the null type enum value by #464. Thank you for your report @Goldziher :+1:
|
|
267
|
-
|
|
268
|
-
### [v3.4.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.4.0) (2020-12-15)
|
|
269
|
-
|
|
270
|
-
- features:
|
|
271
|
-
- Add support for multipart media type by #455. Thank you @wszydlak :+1:
|
|
272
|
-
- Add support for passing config object with NodeJS API usage by #456. Thank you @wszydlak :+1:
|
|
273
|
-
|
|
274
|
-
### [v3.3.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.3.1) (2020-10-05)
|
|
275
|
-
|
|
276
|
-
- fixed:
|
|
277
|
-
- Elements get type "any" instead of the correct one by #448. Thank you for your report @nachtigall-83 :+1:
|
|
278
|
-
|
|
279
|
-
### [v3.3.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.3.0) (2020-07-29)
|
|
280
|
-
|
|
281
|
-
- features:
|
|
282
|
-
- Support the `patternProperties` by #436. Thank you @nfroidure :+1:
|
|
283
|
-
- fixed:
|
|
284
|
-
- Definition generated improperly when multiple instances of a resource are inherited by #279. Thank you @btg5679 :+1:
|
|
285
|
-
- Apply the `prettier` config on `.eslintrc.json`.
|
|
286
|
-
|
|
287
|
-
### [v3.2.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.2.0) (2020-07-20)
|
|
288
|
-
|
|
289
|
-
- features:
|
|
290
|
-
- Add support for application/octet-stream media type by #431. Thank you @MisterChateau :+1:
|
|
291
|
-
|
|
292
|
-
### [v3.1.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.1.1) (2020-06-23)
|
|
293
|
-
|
|
294
|
-
- fixed:
|
|
295
|
-
- Cannot load config file of relative path by #428. Thank you @DamianOsipiuk :+1:
|
|
296
|
-
|
|
297
|
-
### [v3.1.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.1.0) (2020-06-22)
|
|
298
|
-
|
|
299
|
-
- features:
|
|
300
|
-
- Add support for nullable anyOf in OpenApi v3 by #426. Thank you @joost-kersjes-webpower :+1:
|
|
301
|
-
|
|
302
|
-
### [v3.0.3](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.0.3) (2020-06-15)
|
|
303
|
-
|
|
304
|
-
- fixed:
|
|
305
|
-
- Fix the command option example by #422. Thank you @maapteh :+1:
|
|
306
|
-
- Omit load config error on not config option by #425. Thank you @Christian24 :+1:
|
|
307
|
-
|
|
308
|
-
### [v3.0.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.0.2) (2020-06-11)
|
|
309
|
-
|
|
310
|
-
- fixed:
|
|
311
|
-
- Remove old example by #421. Thank you @maapteh :+1:
|
|
312
|
-
|
|
313
|
-
### [v3.0.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.0.1) (2020-06-09)
|
|
314
|
-
|
|
315
|
-
- features:
|
|
316
|
-
- Support the plug-in for pre-process and post-process.
|
|
317
|
-
- Change command line options and Support config file.
|
|
318
|
-
- Use the TypeScript AST for intermediate format.
|
|
319
|
-
|
|
320
172
|
### older versions history
|
|
321
173
|
|
|
322
174
|
[ChangeLogs](https://github.com/horiuchi/dtsgenerator/blob/master/CHANGELOG.md)
|
|
@@ -90,7 +90,7 @@ class DtsGenerator {
|
|
|
90
90
|
const factory = await p({ inputSchemas, option: pc.option });
|
|
91
91
|
if (factory != null) {
|
|
92
92
|
result.push(factory);
|
|
93
|
-
debug('
|
|
93
|
+
debug(' post process plugin:', pc.plugin.meta.name, pc.plugin.meta.description);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
return result;
|
|
@@ -140,6 +140,7 @@ class DtsGenerator {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
normalizeSchemaContent(content) {
|
|
143
|
+
var _a;
|
|
143
144
|
if (typeof content === 'boolean') {
|
|
144
145
|
content = content ? {} : { not: {} };
|
|
145
146
|
}
|
|
@@ -163,7 +164,7 @@ class DtsGenerator {
|
|
|
163
164
|
content = Object.assign(content, work);
|
|
164
165
|
}
|
|
165
166
|
if (content.type === undefined &&
|
|
166
|
-
(content.properties
|
|
167
|
+
((_a = content.properties) !== null && _a !== void 0 ? _a : content.additionalProperties)) {
|
|
167
168
|
content.type = 'object';
|
|
168
169
|
}
|
|
169
170
|
if (content.nullable) {
|
|
@@ -379,9 +380,7 @@ class DtsGenerator {
|
|
|
379
380
|
const additionalItemsNode = getAdditionalItemNode();
|
|
380
381
|
return additionalItemsNode === false
|
|
381
382
|
? ast.buildTupleTypeNode([], 0, 0, additionalItemsNode)
|
|
382
|
-
: ast.buildSimpleArrayNode(additionalItemsNode
|
|
383
|
-
? ast.buildAnyKeyword()
|
|
384
|
-
: additionalItemsNode);
|
|
383
|
+
: ast.buildSimpleArrayNode(additionalItemsNode !== null && additionalItemsNode !== void 0 ? additionalItemsNode : ast.buildAnyKeyword());
|
|
385
384
|
}
|
|
386
385
|
else if (minItems != null &&
|
|
387
386
|
maxItems != null &&
|
package/dist/core/openApiV3.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare namespace OpenApisV3 {
|
|
|
41
41
|
url?: string;
|
|
42
42
|
email?: string;
|
|
43
43
|
}
|
|
44
|
-
type DefaultType = null | any[] |
|
|
44
|
+
type DefaultType = null | any[] | number | boolean | string;
|
|
45
45
|
interface Discriminator {
|
|
46
46
|
propertyName: string;
|
|
47
47
|
mapping?: Strings;
|
|
@@ -242,7 +242,7 @@ export declare namespace OpenApisV3 {
|
|
|
242
242
|
interface ServerVariables {
|
|
243
243
|
[name: string]: ServerVariable;
|
|
244
244
|
}
|
|
245
|
-
type SpecificationExtension = null | number | boolean | string |
|
|
245
|
+
type SpecificationExtension = null | number | boolean | string | any[];
|
|
246
246
|
interface Strings {
|
|
247
247
|
[name: string]: string;
|
|
248
248
|
}
|
package/dist/core/schemaId.js
CHANGED
package/dist/core/type.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.loadPlugin = exports.parseFileContent = exports.readSchemaFromUrl = exports.readSchemasFromFile = exports.readSchemaFromStdin = exports.parseSchema = exports.isJsonSchemaDraft04 = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -82,7 +81,7 @@ async function loadPlugin(name, option) {
|
|
|
82
81
|
if (!option) {
|
|
83
82
|
return undefined;
|
|
84
83
|
}
|
|
85
|
-
const mod = (await
|
|
84
|
+
const mod = (await Promise.resolve(`${name}`).then(s => tslib_1.__importStar(require(s))));
|
|
86
85
|
if (!mod.default) {
|
|
87
86
|
console.warn(`The plugin (${name}) is invalid module. That is not default export format.`);
|
|
88
87
|
return undefined;
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import { CommandOptions } from './commandOptions';
|
|
|
5
5
|
import { PartialConfig } from './core/config';
|
|
6
6
|
export declare function readStream(stream: NodeJS.ReadableStream, encoding?: BufferEncoding): Promise<string>;
|
|
7
7
|
export declare function readUrl(url: string): Promise<string>;
|
|
8
|
-
export declare function buildProxyOptions(url:
|
|
8
|
+
export declare function buildProxyOptions<Uri extends string>(url: Uri): RequestInit | undefined;
|
|
9
9
|
export declare function globFiles(pattern: string, options?: GlobOptions): Promise<string[]>;
|
|
10
10
|
export declare function readConfig(options: CommandOptions): PartialConfig;
|
package/dist/utils.js
CHANGED
|
@@ -4,8 +4,9 @@ exports.readConfig = exports.globFiles = exports.buildProxyOptions = exports.rea
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const url_1 = require("url");
|
|
7
|
-
const glob_1 =
|
|
8
|
-
const
|
|
7
|
+
const glob_1 = require("glob");
|
|
8
|
+
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
9
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
9
10
|
const typescript_1 = require("typescript");
|
|
10
11
|
const commandOptions_1 = require("./commandOptions");
|
|
11
12
|
function readStream(stream, encoding = 'utf8') {
|
|
@@ -40,38 +41,32 @@ function noProxy(url) {
|
|
|
40
41
|
}
|
|
41
42
|
function buildProxyOptions(url) {
|
|
42
43
|
const parsedUrl = new url_1.URL(url);
|
|
43
|
-
let proxyUrl;
|
|
44
44
|
if (!noProxy(parsedUrl)) {
|
|
45
45
|
if (parsedUrl.protocol === 'http:' && process.env.HTTP_PROXY) {
|
|
46
|
-
|
|
46
|
+
return {
|
|
47
|
+
agent: new http_proxy_agent_1.HttpProxyAgent(process.env.HTTP_PROXY),
|
|
48
|
+
};
|
|
47
49
|
}
|
|
48
50
|
else if (parsedUrl.protocol === 'https:' && process.env.HTTPS_PROXY) {
|
|
49
|
-
|
|
51
|
+
return {
|
|
52
|
+
agent: new https_proxy_agent_1.HttpsProxyAgent(process.env.HTTPS_PROXY),
|
|
53
|
+
};
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
if (proxyUrl) {
|
|
53
|
-
const agentOptions = {};
|
|
54
|
-
agentOptions.protocol = proxyUrl.protocol;
|
|
55
|
-
agentOptions.host = proxyUrl.hostname;
|
|
56
|
-
agentOptions.port = proxyUrl.port;
|
|
57
|
-
if (proxyUrl.username) {
|
|
58
|
-
agentOptions.auth = proxyUrl.username + ':' + proxyUrl.password;
|
|
59
|
-
}
|
|
60
|
-
return { agent: (0, https_proxy_agent_1.default)(agentOptions) };
|
|
61
|
-
}
|
|
62
56
|
return undefined;
|
|
63
57
|
}
|
|
64
58
|
exports.buildProxyOptions = buildProxyOptions;
|
|
65
59
|
async function globFiles(pattern, options) {
|
|
66
|
-
const
|
|
67
|
-
|
|
60
|
+
const result = [];
|
|
61
|
+
for await (const r of (0, glob_1.globIterate)(pattern, options !== null && options !== void 0 ? options : {})) {
|
|
68
62
|
if (typeof r === 'string') {
|
|
69
|
-
|
|
63
|
+
result.push(r);
|
|
70
64
|
}
|
|
71
65
|
else {
|
|
72
|
-
|
|
66
|
+
result.push(r.fullpath());
|
|
73
67
|
}
|
|
74
|
-
}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
75
70
|
}
|
|
76
71
|
exports.globFiles = globFiles;
|
|
77
72
|
function readConfig(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtsgenerator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.1",
|
|
4
4
|
"description": "TypeScript d.ts file generator for JSON Schema file",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dtsgen": "bin/dtsgen"
|
|
@@ -41,37 +41,38 @@
|
|
|
41
41
|
"url": "https://github.com/horiuchi/dtsgenerator/issues"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
44
|
+
"node": ">= 16.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"commander": "^
|
|
48
|
-
"cross-fetch": "^
|
|
47
|
+
"commander": "^11.0.0",
|
|
48
|
+
"cross-fetch": "^4.0.0",
|
|
49
49
|
"debug": "^4.3.4",
|
|
50
|
-
"glob": "^
|
|
51
|
-
"
|
|
50
|
+
"glob": "^10.3.3",
|
|
51
|
+
"http-proxy-agent": "^7.0.0",
|
|
52
|
+
"https-proxy-agent": "^7.0.1",
|
|
52
53
|
"js-yaml": "^4.1.0",
|
|
53
|
-
"tslib": "^2.
|
|
54
|
-
"typescript": "^
|
|
54
|
+
"tslib": "^2.6.2",
|
|
55
|
+
"typescript": "^5.1.6"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@dtsgenerator/do-nothing": "^2.
|
|
58
|
-
"@dtsgenerator/eslint-config": "^0.6.
|
|
59
|
-
"@dtsgenerator/replace-namespace": "^1.
|
|
60
|
-
"@dtsgenerator/single-quote": "^1.
|
|
58
|
+
"@dtsgenerator/do-nothing": "^2.6.0",
|
|
59
|
+
"@dtsgenerator/eslint-config": "^0.6.5",
|
|
60
|
+
"@dtsgenerator/replace-namespace": "^1.6.0",
|
|
61
|
+
"@dtsgenerator/single-quote": "^1.7.0",
|
|
61
62
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
62
|
-
"@types/debug": "^4.1.
|
|
63
|
+
"@types/debug": "^4.1.8",
|
|
63
64
|
"@types/glob": "^8.1.0",
|
|
64
65
|
"@types/js-yaml": "^4.0.5",
|
|
65
66
|
"@types/mocha": "^10.0.1",
|
|
66
|
-
"@types/node": "^16.18.
|
|
67
|
+
"@types/node": "^16.18.46",
|
|
67
68
|
"cross-env": "^7.0.3",
|
|
68
|
-
"eslint": "^8.
|
|
69
|
+
"eslint": "^8.47.0",
|
|
69
70
|
"husky": "^8.0.3",
|
|
70
|
-
"lint-staged": "^
|
|
71
|
+
"lint-staged": "^14.0.1",
|
|
71
72
|
"mocha": "^10.2.0",
|
|
72
73
|
"nyc": "^15.1.0",
|
|
73
|
-
"prettier": "^
|
|
74
|
-
"rimraf": "^
|
|
74
|
+
"prettier": "^3.0.2",
|
|
75
|
+
"rimraf": "^5.0.1",
|
|
75
76
|
"source-map-support": "^0.5.21",
|
|
76
77
|
"ts-node": "^10.9.1"
|
|
77
78
|
},
|
package/src/cli.ts
CHANGED
|
@@ -17,21 +17,21 @@ async function loadContents(): Promise<Schema[]> {
|
|
|
17
17
|
ps.push(
|
|
18
18
|
readSchemaFromStdin().then((s) => {
|
|
19
19
|
contents.push(s);
|
|
20
|
-
})
|
|
20
|
+
}),
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
for (const pattern of config.input.files) {
|
|
24
24
|
ps.push(
|
|
25
25
|
readSchemasFromFile(pattern).then((ss) => {
|
|
26
26
|
contents = contents.concat(ss);
|
|
27
|
-
})
|
|
27
|
+
}),
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
for (const url of config.input.urls) {
|
|
31
31
|
ps.push(
|
|
32
32
|
readSchemaFromUrl(url).then((s) => {
|
|
33
33
|
contents.push(s);
|
|
34
|
-
})
|
|
34
|
+
}),
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
await Promise.all(ps);
|
package/src/commandOptions.ts
CHANGED
|
@@ -53,17 +53,17 @@ function parse(options: CommandOptions, argv: string[]): commander.Command {
|
|
|
53
53
|
'--url <url>',
|
|
54
54
|
'input json schema from the url.',
|
|
55
55
|
collectUrl,
|
|
56
|
-
[]
|
|
56
|
+
[],
|
|
57
57
|
)
|
|
58
58
|
.option('--stdin', 'read stdin with other files or urls.')
|
|
59
59
|
.option('-o, --out <file>', 'output filename.')
|
|
60
60
|
.option(
|
|
61
61
|
'-t, --target <version>',
|
|
62
|
-
"Specify ECMAScript target version: 'ES3', 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT' (default)."
|
|
62
|
+
"Specify ECMAScript target version: 'ES3', 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT' (default).",
|
|
63
63
|
)
|
|
64
64
|
.option(
|
|
65
65
|
'--info',
|
|
66
|
-
'for developer mode. output loaded config and plugin details only.'
|
|
66
|
+
'for developer mode. output loaded config and plugin details only.',
|
|
67
67
|
)
|
|
68
68
|
.option('--output-ast', 'output TypeScript AST instead of d.ts file.')
|
|
69
69
|
.addHelpText(
|
|
@@ -76,7 +76,7 @@ Examples:
|
|
|
76
76
|
$ dtsgen -o swaggerSchema.d.ts --url https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json
|
|
77
77
|
$ dtsgen -o petstore.d.ts --url https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore.yaml
|
|
78
78
|
$ dtsgen -c dtsgen-test.json --info
|
|
79
|
-
|
|
79
|
+
`,
|
|
80
80
|
)
|
|
81
81
|
.parse(argv);
|
|
82
82
|
|