@hono/zod-openapi 0.19.2 → 0.19.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 +443 -0
- package/README.md +14 -0
- package/dist/{index.mjs → index.cjs} +50 -27
- package/dist/{index.d.mts → index.d.cts} +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +27 -50
- package/package.json +21 -20
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
# @hono/zod-openapi
|
|
2
|
+
|
|
3
|
+
## 0.19.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1111](https://github.com/honojs/middleware/pull/1111) [`ad4622a8536c8ef9c5feec2e447f36c2629ecbca`](https://github.com/honojs/middleware/commit/ad4622a8536c8ef9c5feec2e447f36c2629ecbca) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Republish v0.19.3 without workspace reference
|
|
8
|
+
|
|
9
|
+
## 0.19.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1106](https://github.com/honojs/middleware/pull/1106) [`448a8fc687cca2bcab2353ea4237f1293706d5e2`](https://github.com/honojs/middleware/commit/448a8fc687cca2bcab2353ea4237f1293706d5e2) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: infer Env correctly if the middleware is `[]`
|
|
14
|
+
|
|
15
|
+
## 0.19.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#995](https://github.com/honojs/middleware/pull/995) [`c279ba2bc5204b1b9effc92c45f129904ea67795`](https://github.com/honojs/middleware/commit/c279ba2bc5204b1b9effc92c45f129904ea67795) Thanks [@luxass](https://github.com/luxass)! - fix(zod-openapi): correctly handle path parameters in basePath
|
|
20
|
+
|
|
21
|
+
## 0.19.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#992](https://github.com/honojs/middleware/pull/992) [`3c738f5ea44f5f5e5cdc14dfeaba5c04188d6373`](https://github.com/honojs/middleware/commit/3c738f5ea44f5f5e5cdc14dfeaba5c04188d6373) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: replace path param strings correctly in basePath
|
|
26
|
+
|
|
27
|
+
## 0.19.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [#984](https://github.com/honojs/middleware/pull/984) [`59c6356aac42d360a06cbc9357921283e455ade4`](https://github.com/honojs/middleware/commit/59c6356aac42d360a06cbc9357921283e455ade4) Thanks [@rmichalak](https://github.com/rmichalak)! - Add ability to exclude specific routes from OpenAPI docs
|
|
32
|
+
|
|
33
|
+
## 0.18.4
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [#955](https://github.com/honojs/middleware/pull/955) [`70a564e268cd6350cfb994e5b5c5626b31a3fcc9`](https://github.com/honojs/middleware/commit/70a564e268cd6350cfb994e5b5c5626b31a3fcc9) Thanks [@luxass](https://github.com/luxass)! - fix: use nested app base paths in openapi schema
|
|
38
|
+
|
|
39
|
+
## 0.18.3
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- [#855](https://github.com/honojs/middleware/pull/855) [`3f63c46fa66bfb7f1d80174bfb160cccfa69f0bc`](https://github.com/honojs/middleware/commit/3f63c46fa66bfb7f1d80174bfb160cccfa69f0bc) Thanks [@jstri](https://github.com/jstri)! - fix: support default response
|
|
44
|
+
|
|
45
|
+
## 0.18.2
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- [#853](https://github.com/honojs/middleware/pull/853) [`a9804afe71fe5876963b3a6f5972a3e5d50dbdca`](https://github.com/honojs/middleware/commit/a9804afe71fe5876963b3a6f5972a3e5d50dbdca) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: return `Response` if response is not text or JSON
|
|
50
|
+
|
|
51
|
+
## 0.18.1
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- [#849](https://github.com/honojs/middleware/pull/849) [`4ebecc61420b6bd94b3a44b8ea58a85654f7ec5d`](https://github.com/honojs/middleware/commit/4ebecc61420b6bd94b3a44b8ea58a85654f7ec5d) Thanks [@askorupskyy](https://github.com/askorupskyy)! - Fix multi-middleware complex object type inference
|
|
56
|
+
|
|
57
|
+
## 0.18.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- [#837](https://github.com/honojs/middleware/pull/837) [`ebd70a0e03c5bb78ba2d39613e10bdc28fe7822b`](https://github.com/honojs/middleware/commit/ebd70a0e03c5bb78ba2d39613e10bdc28fe7822b) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: support `enum`
|
|
62
|
+
|
|
63
|
+
## 0.17.1
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [#828](https://github.com/honojs/middleware/pull/828) [`bbb48ef368d8277b89cb938207093462addf4be3`](https://github.com/honojs/middleware/commit/bbb48ef368d8277b89cb938207093462addf4be3) Thanks [@daniel-pedersen](https://github.com/daniel-pedersen)! - infer env type parameter from middleware
|
|
68
|
+
|
|
69
|
+
## 0.17.0
|
|
70
|
+
|
|
71
|
+
### Minor Changes
|
|
72
|
+
|
|
73
|
+
- [#807](https://github.com/honojs/middleware/pull/807) [`2eec6f6fd90b00e130db5f0b3cfeff806132d98a`](https://github.com/honojs/middleware/commit/2eec6f6fd90b00e130db5f0b3cfeff806132d98a) Thanks [@oberbeck](https://github.com/oberbeck)! - introduce routeMiddleware Env inference
|
|
74
|
+
|
|
75
|
+
## 0.16.3
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- [#756](https://github.com/honojs/middleware/pull/756) [`f6d642afddb31ffb379e71398f6fef534a6621f3`](https://github.com/honojs/middleware/commit/f6d642afddb31ffb379e71398f6fef534a6621f3) Thanks [@lucaschultz](https://github.com/lucaschultz)! - fix: add target property to parameter of validation hook
|
|
80
|
+
|
|
81
|
+
## 0.16.2
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- [#750](https://github.com/honojs/middleware/pull/750) [`98d4ceab9c3eef30d14a457844ce94c3da95b9e9`](https://github.com/honojs/middleware/commit/98d4ceab9c3eef30d14a457844ce94c3da95b9e9) Thanks [@yusukebe](https://github.com/yusukebe)! - chore: bump `@hono/zod-validator`
|
|
86
|
+
|
|
87
|
+
## 0.16.1
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [[`eda35847916cf7f7e84289eba29a8e5517615c6b`](https://github.com/honojs/middleware/commit/eda35847916cf7f7e84289eba29a8e5517615c6b)]:
|
|
92
|
+
- @hono/zod-validator@0.3.0
|
|
93
|
+
|
|
94
|
+
## 0.16.0
|
|
95
|
+
|
|
96
|
+
### Minor Changes
|
|
97
|
+
|
|
98
|
+
- [#710](https://github.com/honojs/middleware/pull/710) [`dadf5ce3c2c134b83420702ca8fe13d6fb8d9390`](https://github.com/honojs/middleware/commit/dadf5ce3c2c134b83420702ca8fe13d6fb8d9390) Thanks [@ameinhardt](https://github.com/ameinhardt)! - Allow multiple mime type response
|
|
99
|
+
|
|
100
|
+
## 0.15.3
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- [#689](https://github.com/honojs/middleware/pull/689) [`c3d48868003ebd215074777a4846af208ddab123`](https://github.com/honojs/middleware/commit/c3d48868003ebd215074777a4846af208ddab123) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: supports `required` for JSON and Form body
|
|
105
|
+
|
|
106
|
+
## 0.15.2
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- [#686](https://github.com/honojs/middleware/pull/686) [`a6ec008fbd8235368b796d2c0edb6adfe8c03cc5`](https://github.com/honojs/middleware/commit/a6ec008fbd8235368b796d2c0edb6adfe8c03cc5) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: don't validate the body if content-type is mismatched
|
|
111
|
+
|
|
112
|
+
## 0.15.1
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- [#656](https://github.com/honojs/middleware/pull/656) [`a04ab70c2c4254eed24efd81d6e5a31553553ec9`](https://github.com/honojs/middleware/commit/a04ab70c2c4254eed24efd81d6e5a31553553ec9) Thanks [@adjsky](https://github.com/adjsky)! - fix(zod-openapi): infer OpenAPIObjectConfig
|
|
117
|
+
|
|
118
|
+
## 0.15.0
|
|
119
|
+
|
|
120
|
+
### Minor Changes
|
|
121
|
+
|
|
122
|
+
- [#645](https://github.com/honojs/middleware/pull/645) [`f38a6166f6ced37ebea3f7cfcefe91d001b0c3b3`](https://github.com/honojs/middleware/commit/f38a6166f6ced37ebea3f7cfcefe91d001b0c3b3) Thanks [@DavidHavl](https://github.com/DavidHavl)! - Support other json content-types such as application/vnd.api+json, application/problem+json, etc.
|
|
123
|
+
|
|
124
|
+
## 0.14.9
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- [#632](https://github.com/honojs/middleware/pull/632) [`a405d0870998f131dbc05a44fae0e6df7ff82521`](https://github.com/honojs/middleware/commit/a405d0870998f131dbc05a44fae0e6df7ff82521) Thanks [@paolostyle](https://github.com/paolostyle)! - expose `extendZodWithOpenApi` from `zod-to-openapi`
|
|
129
|
+
|
|
130
|
+
## 0.14.8
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- [#623](https://github.com/honojs/middleware/pull/623) [`834a97a7b069fe5301f305f18bf271f3842af647`](https://github.com/honojs/middleware/commit/834a97a7b069fe5301f305f18bf271f3842af647) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: support `coerce`
|
|
135
|
+
|
|
136
|
+
## 0.14.7
|
|
137
|
+
|
|
138
|
+
### Patch Changes
|
|
139
|
+
|
|
140
|
+
- [#609](https://github.com/honojs/middleware/pull/609) [`b06bde6ef59368e00c7c75f5866687df2ce47bd9`](https://github.com/honojs/middleware/commit/b06bde6ef59368e00c7c75f5866687df2ce47bd9) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: support a base path
|
|
141
|
+
|
|
142
|
+
## 0.14.6
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- [#607](https://github.com/honojs/middleware/pull/607) [`375c98b145560c855f9000c523734bb2d31990c9`](https://github.com/honojs/middleware/commit/375c98b145560c855f9000c523734bb2d31990c9) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: remove the type error for the hook
|
|
147
|
+
|
|
148
|
+
## 0.14.5
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- [#582](https://github.com/honojs/middleware/pull/582) [`053a85c722833b1f670fe667fb80b3cbe88f9a4d`](https://github.com/honojs/middleware/commit/053a85c722833b1f670fe667fb80b3cbe88f9a4d) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: bump `@asteasolutions/zod-to-openapi`
|
|
153
|
+
|
|
154
|
+
## 0.14.4
|
|
155
|
+
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
158
|
+
- [#576](https://github.com/honojs/middleware/pull/576) [`9a9de504942358be5a77236231e20f5016b6d1a9`](https://github.com/honojs/middleware/commit/9a9de504942358be5a77236231e20f5016b6d1a9) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: use `JSONParsed` for creating a response type
|
|
159
|
+
|
|
160
|
+
## 0.14.3
|
|
161
|
+
|
|
162
|
+
### Patch Changes
|
|
163
|
+
|
|
164
|
+
- [#574](https://github.com/honojs/middleware/pull/574) [`ef9f45ab692c81e1474cfb054f55a2c9fc39bdf8`](https://github.com/honojs/middleware/commit/ef9f45ab692c81e1474cfb054f55a2c9fc39bdf8) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: relax types to support `.refine()` for an object
|
|
165
|
+
|
|
166
|
+
## 0.14.2
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- [#557](https://github.com/honojs/middleware/pull/557) [`69e53644647c156e5f6df0d981eabcd490c4e60b`](https://github.com/honojs/middleware/commit/69e53644647c156e5f6df0d981eabcd490c4e60b) Thanks [@arjunyel](https://github.com/arjunyel)! - Fix OpenAPI yaml with route middleware
|
|
171
|
+
|
|
172
|
+
## 0.14.1
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- Updated dependencies [[`aa055494974eb911ec784e6462691aafefd98125`](https://github.com/honojs/middleware/commit/aa055494974eb911ec784e6462691aafefd98125)]:
|
|
177
|
+
- @hono/zod-validator@0.2.2
|
|
178
|
+
|
|
179
|
+
## 0.14.0
|
|
180
|
+
|
|
181
|
+
### Minor Changes
|
|
182
|
+
|
|
183
|
+
- [#535](https://github.com/honojs/middleware/pull/535) [`a595e4e260040decd871e271c60c5a07c6db4086`](https://github.com/honojs/middleware/commit/a595e4e260040decd871e271c60c5a07c6db4086) Thanks [@taku-hatano](https://github.com/taku-hatano)! - extract range definitions to StatusCode
|
|
184
|
+
|
|
185
|
+
## 0.13.0
|
|
186
|
+
|
|
187
|
+
### Minor Changes
|
|
188
|
+
|
|
189
|
+
- [#532](https://github.com/honojs/middleware/pull/532) [`eeccd4fc2fd63c9d79d7a4911f80fa94d1680983`](https://github.com/honojs/middleware/commit/eeccd4fc2fd63c9d79d7a4911f80fa94d1680983) Thanks [@akineko](https://github.com/akineko)! - feat(zod-openapi): export RouteConfig type
|
|
190
|
+
|
|
191
|
+
## 0.12.2
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- [#529](https://github.com/honojs/middleware/pull/529) [`0a43d2c562f5adb12009f6bdd0e7fb7c06a625e6`](https://github.com/honojs/middleware/commit/0a43d2c562f5adb12009f6bdd0e7fb7c06a625e6) Thanks [@akineko](https://github.com/akineko)! - fix(zod-openapi): update RouteHandler type to support MaybePromise
|
|
196
|
+
|
|
197
|
+
## 0.12.1
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- [#522](https://github.com/honojs/middleware/pull/522) [`2d5ef8255861482cd62deee3d6616a2e21016d53`](https://github.com/honojs/middleware/commit/2d5ef8255861482cd62deee3d6616a2e21016d53) Thanks [@alexzhang1030](https://github.com/alexzhang1030)! - fix(zod-openapi): return type of handler should be MaybePromise
|
|
202
|
+
|
|
203
|
+
## 0.12.0
|
|
204
|
+
|
|
205
|
+
### Minor Changes
|
|
206
|
+
|
|
207
|
+
- [#519](https://github.com/honojs/middleware/pull/519) [`b03484ba056215f0506894f9156cb1e2963cb450`](https://github.com/honojs/middleware/commit/b03484ba056215f0506894f9156cb1e2963cb450) Thanks [@yusukebe](https://github.com/yusukebe)! - feat(zod-openapi): support "status code"
|
|
208
|
+
|
|
209
|
+
## 0.11.1
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- [#510](https://github.com/honojs/middleware/pull/510) [`88113fae8b5bd5d0a7662a1cca426f522da109b7`](https://github.com/honojs/middleware/commit/88113fae8b5bd5d0a7662a1cca426f522da109b7) Thanks [@taku-hatano](https://github.com/taku-hatano)! - Add Promise<void> to Hook
|
|
214
|
+
|
|
215
|
+
## 0.11.0
|
|
216
|
+
|
|
217
|
+
### Minor Changes
|
|
218
|
+
|
|
219
|
+
- [#435](https://github.com/honojs/middleware/pull/435) [`4660092b9ae446e3a6da32628e1bead361769e8a`](https://github.com/honojs/middleware/commit/4660092b9ae446e3a6da32628e1bead361769e8a) Thanks [@RomanNabukhotnyi](https://github.com/RomanNabukhotnyi)! - Add 'middleware' property for route
|
|
220
|
+
|
|
221
|
+
## 0.10.1
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- [#445](https://github.com/honojs/middleware/pull/445) [`110e27246015cac60c8a07cd078c3245b7ddbeeb`](https://github.com/honojs/middleware/commit/110e27246015cac60c8a07cd078c3245b7ddbeeb) Thanks [@fumieval](https://github.com/fumieval)! - Make getRoutingPath property of a RouteConfig non-enumerable
|
|
226
|
+
|
|
227
|
+
## 0.10.0
|
|
228
|
+
|
|
229
|
+
### Minor Changes
|
|
230
|
+
|
|
231
|
+
- [#443](https://github.com/honojs/middleware/pull/443) [`1e0d857ef9f756d1217eaccf37a028be7a107d78`](https://github.com/honojs/middleware/commit/1e0d857ef9f756d1217eaccf37a028be7a107d78) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: bump `zod-to-openapi` supports ESM
|
|
232
|
+
|
|
233
|
+
## 0.9.10
|
|
234
|
+
|
|
235
|
+
### Patch Changes
|
|
236
|
+
|
|
237
|
+
- [#437](https://github.com/honojs/middleware/pull/437) [`9fc8591960ca547cb26a8d32d8f1e2c2f3568b95`](https://github.com/honojs/middleware/commit/9fc8591960ca547cb26a8d32d8f1e2c2f3568b95) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: bump `@hono/zod-validator`
|
|
238
|
+
|
|
239
|
+
## 0.9.9
|
|
240
|
+
|
|
241
|
+
### Patch Changes
|
|
242
|
+
|
|
243
|
+
- [#429](https://github.com/honojs/middleware/pull/429) [`b1f8a5325c3ad5eaa029ca5a82e7ef7adc7e6660`](https://github.com/honojs/middleware/commit/b1f8a5325c3ad5eaa029ca5a82e7ef7adc7e6660) Thanks [@hmnd](https://github.com/hmnd)! - fix: base path not included in client types
|
|
244
|
+
|
|
245
|
+
## 0.9.8
|
|
246
|
+
|
|
247
|
+
### Patch Changes
|
|
248
|
+
|
|
249
|
+
- Updated dependencies [[`4875e1c53146d2c67846b8159d3630d465c2a310`](https://github.com/honojs/middleware/commit/4875e1c53146d2c67846b8159d3630d465c2a310)]:
|
|
250
|
+
- @hono/zod-validator@0.2.0
|
|
251
|
+
|
|
252
|
+
## 0.9.7
|
|
253
|
+
|
|
254
|
+
### Patch Changes
|
|
255
|
+
|
|
256
|
+
- [#408](https://github.com/honojs/middleware/pull/408) [`d4ca1ce98f33ae67100986613144e9d12fb933b3`](https://github.com/honojs/middleware/commit/d4ca1ce98f33ae67100986613144e9d12fb933b3) Thanks [@DavidHavl](https://github.com/DavidHavl)! - fix: Fix basePath method disregarding defaultHook
|
|
257
|
+
|
|
258
|
+
## 0.9.6
|
|
259
|
+
|
|
260
|
+
### Patch Changes
|
|
261
|
+
|
|
262
|
+
- [#356](https://github.com/honojs/middleware/pull/356) [`168a0a6d684a0750ab95802d6316e562061f786c`](https://github.com/honojs/middleware/commit/168a0a6d684a0750ab95802d6316e562061f786c) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: handle `Conflicting names for parameter`
|
|
263
|
+
|
|
264
|
+
## 0.9.5
|
|
265
|
+
|
|
266
|
+
### Patch Changes
|
|
267
|
+
|
|
268
|
+
- [#316](https://github.com/honojs/middleware/pull/316) [`5eeb555`](https://github.com/honojs/middleware/commit/5eeb555c8958fb890e80262e3dbf532f3c8c1e55) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: supports named params in nested routes
|
|
269
|
+
|
|
270
|
+
## 0.9.4
|
|
271
|
+
|
|
272
|
+
### Patch Changes
|
|
273
|
+
|
|
274
|
+
- [#313](https://github.com/honojs/middleware/pull/313) [`b8219d9`](https://github.com/honojs/middleware/commit/b8219d9b68e6aba7466705d0787dbdd15b808b06) Thanks [@WildEgo](https://github.com/WildEgo)! - change: Export Hook in @hono/zod-openapi
|
|
275
|
+
|
|
276
|
+
## 0.9.3
|
|
277
|
+
|
|
278
|
+
### Patch Changes
|
|
279
|
+
|
|
280
|
+
- [#292](https://github.com/honojs/middleware/pull/292) [`7ded22a`](https://github.com/honojs/middleware/commit/7ded22a57edba4d30144fd7641d9502eecefc1ac) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: bump Hono for peerDependencies and add tests
|
|
281
|
+
|
|
282
|
+
## 0.9.2
|
|
283
|
+
|
|
284
|
+
### Patch Changes
|
|
285
|
+
|
|
286
|
+
- [#286](https://github.com/honojs/middleware/pull/286) [`8178ba0`](https://github.com/honojs/middleware/commit/8178ba094f9bcc289b57f017a79fb075b08566cb) Thanks [@fahchen](https://github.com/fahchen)! - use z.input to infer input types of the request
|
|
287
|
+
|
|
288
|
+
## 0.9.1
|
|
289
|
+
|
|
290
|
+
### Patch Changes
|
|
291
|
+
|
|
292
|
+
- [#287](https://github.com/honojs/middleware/pull/287) [`1568b92`](https://github.com/honojs/middleware/commit/1568b920de1e45b963d1812c32932fad01dbe2fe) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: Strict type checking of return values
|
|
293
|
+
|
|
294
|
+
## 0.9.0
|
|
295
|
+
|
|
296
|
+
### Minor Changes
|
|
297
|
+
|
|
298
|
+
- [#272](https://github.com/honojs/middleware/pull/272) [`d4aa8ec`](https://github.com/honojs/middleware/commit/d4aa8ec5ad38942c1606642dc4676a92a7c006a8) Thanks [@Karibash](https://github.com/Karibash)! - Make context accessible in the doc route
|
|
299
|
+
|
|
300
|
+
## 0.8.6
|
|
301
|
+
|
|
302
|
+
### Patch Changes
|
|
303
|
+
|
|
304
|
+
- [#260](https://github.com/honojs/middleware/pull/260) [`ba83a26`](https://github.com/honojs/middleware/commit/ba83a268e010a7b18172e7de01e3901b58a7ec62) Thanks [@Karibash](https://github.com/Karibash)! - Make it possible to do method chaining even for doc methods
|
|
305
|
+
|
|
306
|
+
## 0.8.5
|
|
307
|
+
|
|
308
|
+
### Patch Changes
|
|
309
|
+
|
|
310
|
+
- [#258](https://github.com/honojs/middleware/pull/258) [`368c352`](https://github.com/honojs/middleware/commit/368c3520fa8a15657e8e42313bbfde3d87b0183b) Thanks [@Karibash](https://github.com/Karibash)! - Fix a bug that slashes were duplicated when mounting a path using the route method
|
|
311
|
+
|
|
312
|
+
## 0.8.4
|
|
313
|
+
|
|
314
|
+
### Patch Changes
|
|
315
|
+
|
|
316
|
+
- [#255](https://github.com/honojs/middleware/pull/255) [`129f468`](https://github.com/honojs/middleware/commit/129f4680a2c050ec49a0422d735e0d173d7b5faf) Thanks [@Karibash](https://github.com/Karibash)! - Fix incorrect specification of the exports field in package.json
|
|
317
|
+
|
|
318
|
+
## 0.8.3
|
|
319
|
+
|
|
320
|
+
### Patch Changes
|
|
321
|
+
|
|
322
|
+
- [#222](https://github.com/honojs/middleware/pull/222) [`73ab82a`](https://github.com/honojs/middleware/commit/73ab82a90253a0dbc536251787ff5713981a4075) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: import types correctly
|
|
323
|
+
|
|
324
|
+
## 0.8.2
|
|
325
|
+
|
|
326
|
+
### Patch Changes
|
|
327
|
+
|
|
328
|
+
- [#217](https://github.com/honojs/middleware/pull/217) [`a80c84b`](https://github.com/honojs/middleware/commit/a80c84ba07153f8521c1fc0286abef0623c99b5c) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: bump Hono for `peerDependencies`
|
|
329
|
+
|
|
330
|
+
## 0.8.1
|
|
331
|
+
|
|
332
|
+
### Patch Changes
|
|
333
|
+
|
|
334
|
+
- [#211](https://github.com/honojs/middleware/pull/211) [`6ca8e8d`](https://github.com/honojs/middleware/commit/6ca8e8d8de85dde7b9c25bfd5665aa32e233402e) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: relax input types
|
|
335
|
+
|
|
336
|
+
## 0.8.0
|
|
337
|
+
|
|
338
|
+
### Minor Changes
|
|
339
|
+
|
|
340
|
+
- [#206](https://github.com/honojs/middleware/pull/206) [`2d2fdd0`](https://github.com/honojs/middleware/commit/2d2fdd0379a31320b06f6d1a9e4634bfe1b7c657) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: allows the response to be `Response` not just `TypedResponse`.
|
|
341
|
+
|
|
342
|
+
## 0.7.2
|
|
343
|
+
|
|
344
|
+
### Patch Changes
|
|
345
|
+
|
|
346
|
+
- [#189](https://github.com/honojs/middleware/pull/189) [`58167f3`](https://github.com/honojs/middleware/commit/58167f3b7f3c564334f5182529f0ddb29ace0af1) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: publish as cjs by default
|
|
347
|
+
|
|
348
|
+
## 0.7.1
|
|
349
|
+
|
|
350
|
+
### Patch Changes
|
|
351
|
+
|
|
352
|
+
- [#182](https://github.com/honojs/middleware/pull/182) [`9aefddc`](https://github.com/honojs/middleware/commit/9aefddc45d048e5e51eb36d81cb878c62a72ba9f) Thanks [@ZerNico](https://github.com/ZerNico)! - properly convert openapi path type to hono
|
|
353
|
+
|
|
354
|
+
## 0.7.0
|
|
355
|
+
|
|
356
|
+
### Minor Changes
|
|
357
|
+
|
|
358
|
+
- [#170](https://github.com/honojs/middleware/pull/170) [`9c45dbc`](https://github.com/honojs/middleware/commit/9c45dbc41d46ae4d04d9351757020d7ad528b400) Thanks [@msutkowski](https://github.com/msutkowski)! - Add defaultHook as an option for OpenAPIHono
|
|
359
|
+
|
|
360
|
+
### Patch Changes
|
|
361
|
+
|
|
362
|
+
- [#179](https://github.com/honojs/middleware/pull/179) [`047eca5`](https://github.com/honojs/middleware/commit/047eca5ca99085ee8c4f1581b17c8ebeae6afc82) Thanks [@yusukebe](https://github.com/yusukebe)! - fix(zod-openapi): enable `basePath()`
|
|
363
|
+
|
|
364
|
+
- [#176](https://github.com/honojs/middleware/pull/176) [`fb63ef4`](https://github.com/honojs/middleware/commit/fb63ef413cb7b843aebe756a5322bdd10ba74500) Thanks [@yusukebe](https://github.com/yusukebe)! - fix(zod-openapi): make multiple routes types correct for `hc`
|
|
365
|
+
|
|
366
|
+
- Updated dependencies [[`a9123dd`](https://github.com/honojs/middleware/commit/a9123dd9e3e90d4d73f495d6b407ebacf9ea0ad8)]:
|
|
367
|
+
- @hono/zod-validator@0.1.9
|
|
368
|
+
|
|
369
|
+
## 0.6.0
|
|
370
|
+
|
|
371
|
+
### Minor Changes
|
|
372
|
+
|
|
373
|
+
- [#167](https://github.com/honojs/middleware/pull/167) [`dbebf74`](https://github.com/honojs/middleware/commit/dbebf747c9c7ca94bf22259772d8b1e0623ce68d) Thanks [@exsjabe](https://github.com/exsjabe)! - Export types that allow for separate declaratins of route handlers and hooks
|
|
374
|
+
|
|
375
|
+
## 0.5.1
|
|
376
|
+
|
|
377
|
+
### Patch Changes
|
|
378
|
+
|
|
379
|
+
- [#164](https://github.com/honojs/middleware/pull/164) [`62a97fd`](https://github.com/honojs/middleware/commit/62a97fda6a784f11549fff442978677642d2b218) Thanks [@yusukebe](https://github.com/yusukebe)! - fix(zod-openapi): use `z.output` for types after validation
|
|
380
|
+
|
|
381
|
+
## 0.5.0
|
|
382
|
+
|
|
383
|
+
### Minor Changes
|
|
384
|
+
|
|
385
|
+
- [#161](https://github.com/honojs/middleware/pull/161) [`05b8e9a`](https://github.com/honojs/middleware/commit/05b8e9a7511874f7e9dcb84b9dcfa97ca458ae4e) Thanks [@naporin0624](https://github.com/naporin0624)! - Add getRoutingPath to the return value of createRoute.
|
|
386
|
+
|
|
387
|
+
## 0.4.0
|
|
388
|
+
|
|
389
|
+
### Minor Changes
|
|
390
|
+
|
|
391
|
+
- [#153](https://github.com/honojs/middleware/pull/153) [`430088e`](https://github.com/honojs/middleware/commit/430088e17569a12e354c80c1d6da67a9ecbfdffe) Thanks [@mikestopcontinues](https://github.com/mikestopcontinues)! - Merge subapps' spec definitions into main app
|
|
392
|
+
|
|
393
|
+
- [#153](https://github.com/honojs/middleware/pull/153) [`430088e`](https://github.com/honojs/middleware/commit/430088e17569a12e354c80c1d6da67a9ecbfdffe) Thanks [@mikestopcontinues](https://github.com/mikestopcontinues)! - Support v3.1 spec output
|
|
394
|
+
|
|
395
|
+
- [#153](https://github.com/honojs/middleware/pull/153) [`430088e`](https://github.com/honojs/middleware/commit/430088e17569a12e354c80c1d6da67a9ecbfdffe) Thanks [@mikestopcontinues](https://github.com/mikestopcontinues)! - OpenAPIHono constructor supports init object
|
|
396
|
+
|
|
397
|
+
## 0.3.1
|
|
398
|
+
|
|
399
|
+
### Patch Changes
|
|
400
|
+
|
|
401
|
+
- [#155](https://github.com/honojs/middleware/pull/155) [`804caac`](https://github.com/honojs/middleware/commit/804caac19123e0b6d9a3f33b686051f1f111ee1f) Thanks [@yusukebe](https://github.com/yusukebe)! - fix(zod-openapi): support multiple params
|
|
402
|
+
|
|
403
|
+
## 0.3.0
|
|
404
|
+
|
|
405
|
+
### Minor Changes
|
|
406
|
+
|
|
407
|
+
- [#150](https://github.com/honojs/middleware/pull/150) [`1006cbc`](https://github.com/honojs/middleware/commit/1006cbca6b6636340afe10f7680511bab2046b47) Thanks [@yusukebe](https://github.com/yusukebe)! - feat(zod-openapi): make `app.openAPIRegistry` public
|
|
408
|
+
|
|
409
|
+
### Patch Changes
|
|
410
|
+
|
|
411
|
+
- [#148](https://github.com/honojs/middleware/pull/148) [`1bfd648`](https://github.com/honojs/middleware/commit/1bfd648df8dfcd659c14514b977de945d3806b7d) Thanks [@yusukebe](https://github.com/yusukebe)! - fix(zod-openapi): fix a type error
|
|
412
|
+
|
|
413
|
+
## 0.2.0
|
|
414
|
+
|
|
415
|
+
### Minor Changes
|
|
416
|
+
|
|
417
|
+
- [#141](https://github.com/honojs/middleware/pull/141) [`f334e99`](https://github.com/honojs/middleware/commit/f334e99251cdabc8be9334eec7eb7d9a450d8e35) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: support `headers` and `cookies`
|
|
418
|
+
|
|
419
|
+
## 0.1.2
|
|
420
|
+
|
|
421
|
+
### Patch Changes
|
|
422
|
+
|
|
423
|
+
- [#139](https://github.com/honojs/middleware/pull/139) [`991b859`](https://github.com/honojs/middleware/commit/991b85915a63d1fd15cda52078f6401c17d3879f) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: bump up Hono version
|
|
424
|
+
|
|
425
|
+
## 0.1.1
|
|
426
|
+
|
|
427
|
+
### Patch Changes
|
|
428
|
+
|
|
429
|
+
- [#132](https://github.com/honojs/middleware/pull/132) [`2dbc823`](https://github.com/honojs/middleware/commit/2dbc823b29a95e6c81bedc5416c08f15ac97288d) Thanks [@yusukebe](https://github.com/yusukebe)! - fix path param format `:id` to `{id}`
|
|
430
|
+
|
|
431
|
+
## 0.1.0
|
|
432
|
+
|
|
433
|
+
### Minor Changes
|
|
434
|
+
|
|
435
|
+
- [#124](https://github.com/honojs/middleware/pull/124) [`e6b20c6`](https://github.com/honojs/middleware/commit/e6b20c64b61654dc742b233ad09d764c71db7186) Thanks [@yusukebe](https://github.com/yusukebe)! - feat(zod-openapi): support RPC-mode
|
|
436
|
+
|
|
437
|
+
## 0.0.1
|
|
438
|
+
|
|
439
|
+
### Patch Changes
|
|
440
|
+
|
|
441
|
+
- [#121](https://github.com/honojs/middleware/pull/121) [`1233c00`](https://github.com/honojs/middleware/commit/1233c00875827749599880ade5830f8a1e7d73e8) Thanks [@yusukebe](https://github.com/yusukebe)! - docs: fixed readme
|
|
442
|
+
|
|
443
|
+
- [#118](https://github.com/honojs/middleware/pull/118) [`7b89803`](https://github.com/honojs/middleware/commit/7b898034a50c9bfa08872e28dcaa066ea55d9e3d) Thanks [@yusukebe](https://github.com/yusukebe)! - introduce Zod OpenAPI
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Zod OpenAPI Hono
|
|
2
2
|
|
|
3
|
+
[](https://codecov.io/github/honojs/middleware)
|
|
4
|
+
|
|
3
5
|
**Zod OpenAPI Hono** is an extended Hono class that supports OpenAPI. With it, you can validate values and types using [**Zod**](https://zod.dev/) and generate OpenAPI Swagger documentation. This is based on [**Zod to OpenAPI**](https://github.com/asteasolutions/zod-to-openapi) (thanks a lot!). For details on creating schemas and defining routes, please refer to [the "Zod to OpenAPI" resource](https://github.com/asteasolutions/zod-to-openapi).
|
|
4
6
|
|
|
5
7
|
_Note: This is not standalone middleware but is hosted on the monorepo "[github.com/honojs/middleware](https://github.com/honojs/middleware)"._
|
|
@@ -470,6 +472,18 @@ Be careful when combining `OpenAPIHono` instances with plain `Hono` instances. `
|
|
|
470
472
|
|
|
471
473
|
If you're migrating from plain `Hono` to `OpenAPIHono`, we recommend porting your top-level app, then working your way down the router tree.
|
|
472
474
|
|
|
475
|
+
When using the `.route()` method to mount a child OpenAPIHono app that uses path parameters, you should use the Hono *:param* syntax in the parent route path, rather than the OpenAPI *{param}* syntax:
|
|
476
|
+
|
|
477
|
+
```
|
|
478
|
+
const bookActionsApp = new OpenAPIHono()
|
|
479
|
+
...
|
|
480
|
+
// ❌ Incorrect: This will not match the route
|
|
481
|
+
app.route('/books/{bookId}', bookActionsApp)
|
|
482
|
+
|
|
483
|
+
// ✅ Using Hono parameter syntax
|
|
484
|
+
app.route('/books/:bookId', bookActionsApp)
|
|
485
|
+
```
|
|
486
|
+
|
|
473
487
|
### Header keys
|
|
474
488
|
|
|
475
489
|
Header keys that you define in your schema must be in lowercase.
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
1
20
|
// src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
extendZodWithOpenApi
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
OpenAPIHono: () => OpenAPIHono,
|
|
24
|
+
createRoute: () => createRoute,
|
|
25
|
+
extendZodWithOpenApi: () => import_zod_to_openapi.extendZodWithOpenApi,
|
|
26
|
+
z: () => import_zod.z
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var import_zod_to_openapi = require("@asteasolutions/zod-to-openapi");
|
|
30
|
+
var import_zod_validator = require("@hono/zod-validator");
|
|
31
|
+
var import_hono = require("hono");
|
|
32
|
+
var import_url = require("hono/utils/url");
|
|
33
|
+
var import_zod = require("zod");
|
|
34
|
+
var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
13
35
|
openAPIRegistry;
|
|
14
36
|
defaultHook;
|
|
15
37
|
constructor(init) {
|
|
16
38
|
super(init);
|
|
17
|
-
this.openAPIRegistry = new OpenAPIRegistry();
|
|
39
|
+
this.openAPIRegistry = new import_zod_to_openapi.OpenAPIRegistry();
|
|
18
40
|
this.defaultHook = init?.defaultHook;
|
|
19
41
|
}
|
|
20
42
|
/**
|
|
@@ -54,19 +76,19 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
54
76
|
}
|
|
55
77
|
const validators = [];
|
|
56
78
|
if (route.request?.query) {
|
|
57
|
-
const validator = zValidator("query", route.request.query, hook);
|
|
79
|
+
const validator = (0, import_zod_validator.zValidator)("query", route.request.query, hook);
|
|
58
80
|
validators.push(validator);
|
|
59
81
|
}
|
|
60
82
|
if (route.request?.params) {
|
|
61
|
-
const validator = zValidator("param", route.request.params, hook);
|
|
83
|
+
const validator = (0, import_zod_validator.zValidator)("param", route.request.params, hook);
|
|
62
84
|
validators.push(validator);
|
|
63
85
|
}
|
|
64
86
|
if (route.request?.headers) {
|
|
65
|
-
const validator = zValidator("header", route.request.headers, hook);
|
|
87
|
+
const validator = (0, import_zod_validator.zValidator)("header", route.request.headers, hook);
|
|
66
88
|
validators.push(validator);
|
|
67
89
|
}
|
|
68
90
|
if (route.request?.cookies) {
|
|
69
|
-
const validator = zValidator("cookie", route.request.cookies, hook);
|
|
91
|
+
const validator = (0, import_zod_validator.zValidator)("cookie", route.request.cookies, hook);
|
|
70
92
|
validators.push(validator);
|
|
71
93
|
}
|
|
72
94
|
const bodyContent = route.request?.body?.content;
|
|
@@ -76,11 +98,11 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
76
98
|
continue;
|
|
77
99
|
}
|
|
78
100
|
const schema = bodyContent[mediaType]["schema"];
|
|
79
|
-
if (!(schema instanceof ZodType)) {
|
|
101
|
+
if (!(schema instanceof import_zod.ZodType)) {
|
|
80
102
|
continue;
|
|
81
103
|
}
|
|
82
104
|
if (isJSONContentType(mediaType)) {
|
|
83
|
-
const validator = zValidator("json", schema, hook);
|
|
105
|
+
const validator = (0, import_zod_validator.zValidator)("json", schema, hook);
|
|
84
106
|
if (route.request?.body?.required) {
|
|
85
107
|
validators.push(validator);
|
|
86
108
|
} else {
|
|
@@ -97,7 +119,7 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
97
119
|
}
|
|
98
120
|
}
|
|
99
121
|
if (isFormContentType(mediaType)) {
|
|
100
|
-
const validator = zValidator("form", schema, hook);
|
|
122
|
+
const validator = (0, import_zod_validator.zValidator)("form", schema, hook);
|
|
101
123
|
if (route.request?.body?.required) {
|
|
102
124
|
validators.push(validator);
|
|
103
125
|
} else {
|
|
@@ -126,12 +148,12 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
126
148
|
return this;
|
|
127
149
|
};
|
|
128
150
|
getOpenAPIDocument = (config) => {
|
|
129
|
-
const generator = new OpenApiGeneratorV3(this.openAPIRegistry.definitions);
|
|
151
|
+
const generator = new import_zod_to_openapi.OpenApiGeneratorV3(this.openAPIRegistry.definitions);
|
|
130
152
|
const document = generator.generateDocument(config);
|
|
131
153
|
return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
|
|
132
154
|
};
|
|
133
155
|
getOpenAPI31Document = (config) => {
|
|
134
|
-
const generator = new OpenApiGeneratorV31(this.openAPIRegistry.definitions);
|
|
156
|
+
const generator = new import_zod_to_openapi.OpenApiGeneratorV31(this.openAPIRegistry.definitions);
|
|
135
157
|
const document = generator.generateDocument(config);
|
|
136
158
|
return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
|
|
137
159
|
};
|
|
@@ -170,7 +192,7 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
170
192
|
case "route":
|
|
171
193
|
return this.openAPIRegistry.registerPath({
|
|
172
194
|
...def.route,
|
|
173
|
-
path: mergePath(
|
|
195
|
+
path: (0, import_url.mergePath)(
|
|
174
196
|
pathForOpenAPI,
|
|
175
197
|
// @ts-expect-error _basePath is private
|
|
176
198
|
app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
|
|
@@ -180,7 +202,7 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
180
202
|
case "webhook":
|
|
181
203
|
return this.openAPIRegistry.registerWebhook({
|
|
182
204
|
...def.webhook,
|
|
183
|
-
path: mergePath(
|
|
205
|
+
path: (0, import_url.mergePath)(
|
|
184
206
|
pathForOpenAPI,
|
|
185
207
|
// @ts-expect-error _basePath is private
|
|
186
208
|
app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
|
|
@@ -215,11 +237,11 @@ var createRoute = (routeConfig) => {
|
|
|
215
237
|
};
|
|
216
238
|
return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
|
|
217
239
|
};
|
|
218
|
-
extendZodWithOpenApi(z);
|
|
240
|
+
(0, import_zod_to_openapi.extendZodWithOpenApi)(import_zod.z);
|
|
219
241
|
function addBasePathToDocument(document, basePath) {
|
|
220
242
|
const updatedPaths = {};
|
|
221
243
|
Object.keys(document.paths).forEach((path) => {
|
|
222
|
-
updatedPaths[mergePath(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
|
|
244
|
+
updatedPaths[(0, import_url.mergePath)(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
|
|
223
245
|
});
|
|
224
246
|
return {
|
|
225
247
|
...document,
|
|
@@ -232,9 +254,10 @@ function isJSONContentType(contentType) {
|
|
|
232
254
|
function isFormContentType(contentType) {
|
|
233
255
|
return contentType.startsWith("multipart/form-data") || contentType.startsWith("application/x-www-form-urlencoded");
|
|
234
256
|
}
|
|
235
|
-
export
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
236
259
|
OpenAPIHono,
|
|
237
260
|
createRoute,
|
|
238
261
|
extendZodWithOpenApi,
|
|
239
262
|
z
|
|
240
|
-
};
|
|
263
|
+
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
|
+
import * as _asteasolutions_zod_to_openapi_dist_v3_1_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.1/openapi-generator';
|
|
2
3
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
|
-
import
|
|
4
|
+
import * as _asteasolutions_zod_to_openapi_dist_v3_0_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
|
+
import { RouteConfig as RouteConfig$1, ZodRequestBody, ZodContentObject, ZodMediaTypeObject, OpenApiGeneratorV3, OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
4
6
|
export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
5
7
|
import { MiddlewareHandler, TypedResponse, Env, ValidationTargets, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
8
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode, StatusCode } from 'hono/utils/http-status';
|
|
10
|
+
import { SimplifyDeepArray, JSONValue, JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
11
|
+
import { ZodSchema, z, ZodError, ZodType } from 'zod';
|
|
10
12
|
export { z } from 'zod';
|
|
11
13
|
|
|
12
14
|
type MaybePromise<T> = Promise<T> | T;
|
|
@@ -72,8 +74,12 @@ type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode;
|
|
|
72
74
|
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T;
|
|
73
75
|
type DefinedStatusCodes<R extends RouteConfig> = keyof R['responses'] & RouteConfigStatusCode;
|
|
74
76
|
type RouteConfigToTypedResponse<R extends RouteConfig> = {
|
|
75
|
-
[Status in DefinedStatusCodes<R>]:
|
|
76
|
-
|
|
77
|
+
[Status in DefinedStatusCodes<R>]: R['responses'][Status] extends {
|
|
78
|
+
content: infer Content;
|
|
79
|
+
} ? undefined extends Content ? never : ReturnJsonOrTextOrResponse<keyof R['responses'][Status]['content'], ExtractContent<R['responses'][Status]['content']>, Status> : TypedResponse<{}, ExtractStatusCode<Status>, string>;
|
|
80
|
+
}[DefinedStatusCodes<R>] | ('default' extends keyof R['responses'] ? R['responses']['default'] extends {
|
|
81
|
+
content: infer Content;
|
|
82
|
+
} ? undefined extends Content ? never : ReturnJsonOrTextOrResponse<keyof Content, ExtractContent<Content>, Exclude<StatusCode, ExtractStatusCode<DefinedStatusCodes<R>>>> : TypedResponse<{}, Exclude<StatusCode, ExtractStatusCode<DefinedStatusCodes<R>>>, string> : never);
|
|
77
83
|
type Hook<T, E extends Env, P extends string, R> = (result: {
|
|
78
84
|
target: keyof ValidationTargets;
|
|
79
85
|
} & ({
|
|
@@ -120,7 +126,7 @@ type MiddlewareToHandlerType<M extends MiddlewareHandler<any, any, any>[]> = M e
|
|
|
120
126
|
OfHandlerType<First>['path'], // Keep path from First
|
|
121
127
|
OfHandlerType<First>['input']>,
|
|
122
128
|
...Rest
|
|
123
|
-
]> : never : never : never : M extends [infer Last] ? Last :
|
|
129
|
+
]> : never : never : never : M extends [infer Last] ? Last : MiddlewareHandler<Env>;
|
|
124
130
|
type RouteMiddlewareParams<R extends RouteConfig> = OfHandlerType<MiddlewareToHandlerType<AsArray<R['middleware']>>>;
|
|
125
131
|
type RouteConfigToEnv<R extends RouteConfig> = RouteMiddlewareParams<R> extends never ? Env : RouteMiddlewareParams<R>['env'];
|
|
126
132
|
type RouteHandler<R extends RouteConfig, E extends Env = RouteConfigToEnv<R>, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I, R extends {
|
|
@@ -170,7 +176,7 @@ declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath e
|
|
|
170
176
|
* }
|
|
171
177
|
*)
|
|
172
178
|
*/
|
|
173
|
-
openapi: <R extends RouteConfig, I extends Input =
|
|
179
|
+
openapi: <R extends RouteConfig, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>({ middleware: routeMiddleware, hide, ...route }: R, handler: Handler<R["middleware"] extends MiddlewareHandler[] | MiddlewareHandler ? RouteMiddlewareParams<R>["env"] & E : E, P, I, R extends {
|
|
174
180
|
responses: {
|
|
175
181
|
[statusCode: number]: {
|
|
176
182
|
content: {
|
|
@@ -186,11 +192,11 @@ declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath e
|
|
|
186
192
|
};
|
|
187
193
|
};
|
|
188
194
|
};
|
|
189
|
-
} ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined> | undefined) => OpenAPIHono<E, S & ToSchema<R[
|
|
190
|
-
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject
|
|
191
|
-
getOpenAPI31Document: (config: OpenAPIObjectConfig) => openapi3_ts_oas31.OpenAPIObject
|
|
192
|
-
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<
|
|
193
|
-
doc31: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<
|
|
195
|
+
} ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], MergePath<BasePath, P>, I, RouteConfigToTypedResponse<R>>, BasePath>;
|
|
196
|
+
getOpenAPIDocument: (config: OpenAPIObjectConfig) => ReturnType<(config: _asteasolutions_zod_to_openapi_dist_v3_0_openapi_generator.OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject>;
|
|
197
|
+
getOpenAPI31Document: (config: OpenAPIObjectConfig) => ReturnType<(config: _asteasolutions_zod_to_openapi_dist_v3_1_openapi_generator.OpenAPIObjectConfigV31) => openapi3_ts_oas31.OpenAPIObject>;
|
|
198
|
+
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
199
|
+
doc31: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
194
200
|
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): OpenAPIHono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>;
|
|
195
201
|
route<SubPath extends string>(path: SubPath): Hono<E, RemoveBlankRecord<S>, BasePath>;
|
|
196
202
|
basePath<SubPath extends string>(path: SubPath): OpenAPIHono<E, S, MergePath<BasePath, SubPath>>;
|
|
@@ -199,7 +205,7 @@ type RoutingPath<P extends string> = P extends `${infer Head}/{${infer Param}}${
|
|
|
199
205
|
declare const createRoute: <P extends string, R extends Omit<RouteConfig, "path"> & {
|
|
200
206
|
path: P;
|
|
201
207
|
}>(routeConfig: R) => R & {
|
|
202
|
-
getRoutingPath(): RoutingPath<R[
|
|
208
|
+
getRoutingPath(): RoutingPath<R["path"]>;
|
|
203
209
|
};
|
|
204
210
|
|
|
205
211
|
export { type DeepSimplify, type Hook, type MiddlewareToHandlerType, type OfHandlerType, OpenAPIHono, type OpenAPIHonoOptions, type OpenAPIObjectConfigure, type RouteConfig, type RouteConfigToEnv, type RouteConfigToTypedResponse, type RouteHandler, type RouteHook, createRoute };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
|
+
import * as _asteasolutions_zod_to_openapi_dist_v3_1_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.1/openapi-generator';
|
|
2
3
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
|
-
import
|
|
4
|
+
import * as _asteasolutions_zod_to_openapi_dist_v3_0_openapi_generator from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
|
+
import { RouteConfig as RouteConfig$1, ZodRequestBody, ZodContentObject, ZodMediaTypeObject, OpenApiGeneratorV3, OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
4
6
|
export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
5
7
|
import { MiddlewareHandler, TypedResponse, Env, ValidationTargets, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
8
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode, StatusCode } from 'hono/utils/http-status';
|
|
10
|
+
import { SimplifyDeepArray, JSONValue, JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
11
|
+
import { ZodSchema, z, ZodError, ZodType } from 'zod';
|
|
10
12
|
export { z } from 'zod';
|
|
11
13
|
|
|
12
14
|
type MaybePromise<T> = Promise<T> | T;
|
|
@@ -72,8 +74,12 @@ type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode;
|
|
|
72
74
|
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T;
|
|
73
75
|
type DefinedStatusCodes<R extends RouteConfig> = keyof R['responses'] & RouteConfigStatusCode;
|
|
74
76
|
type RouteConfigToTypedResponse<R extends RouteConfig> = {
|
|
75
|
-
[Status in DefinedStatusCodes<R>]:
|
|
76
|
-
|
|
77
|
+
[Status in DefinedStatusCodes<R>]: R['responses'][Status] extends {
|
|
78
|
+
content: infer Content;
|
|
79
|
+
} ? undefined extends Content ? never : ReturnJsonOrTextOrResponse<keyof R['responses'][Status]['content'], ExtractContent<R['responses'][Status]['content']>, Status> : TypedResponse<{}, ExtractStatusCode<Status>, string>;
|
|
80
|
+
}[DefinedStatusCodes<R>] | ('default' extends keyof R['responses'] ? R['responses']['default'] extends {
|
|
81
|
+
content: infer Content;
|
|
82
|
+
} ? undefined extends Content ? never : ReturnJsonOrTextOrResponse<keyof Content, ExtractContent<Content>, Exclude<StatusCode, ExtractStatusCode<DefinedStatusCodes<R>>>> : TypedResponse<{}, Exclude<StatusCode, ExtractStatusCode<DefinedStatusCodes<R>>>, string> : never);
|
|
77
83
|
type Hook<T, E extends Env, P extends string, R> = (result: {
|
|
78
84
|
target: keyof ValidationTargets;
|
|
79
85
|
} & ({
|
|
@@ -120,7 +126,7 @@ type MiddlewareToHandlerType<M extends MiddlewareHandler<any, any, any>[]> = M e
|
|
|
120
126
|
OfHandlerType<First>['path'], // Keep path from First
|
|
121
127
|
OfHandlerType<First>['input']>,
|
|
122
128
|
...Rest
|
|
123
|
-
]> : never : never : never : M extends [infer Last] ? Last :
|
|
129
|
+
]> : never : never : never : M extends [infer Last] ? Last : MiddlewareHandler<Env>;
|
|
124
130
|
type RouteMiddlewareParams<R extends RouteConfig> = OfHandlerType<MiddlewareToHandlerType<AsArray<R['middleware']>>>;
|
|
125
131
|
type RouteConfigToEnv<R extends RouteConfig> = RouteMiddlewareParams<R> extends never ? Env : RouteMiddlewareParams<R>['env'];
|
|
126
132
|
type RouteHandler<R extends RouteConfig, E extends Env = RouteConfigToEnv<R>, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I, R extends {
|
|
@@ -170,7 +176,7 @@ declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath e
|
|
|
170
176
|
* }
|
|
171
177
|
*)
|
|
172
178
|
*/
|
|
173
|
-
openapi: <R extends RouteConfig, I extends Input =
|
|
179
|
+
openapi: <R extends RouteConfig, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>({ middleware: routeMiddleware, hide, ...route }: R, handler: Handler<R["middleware"] extends MiddlewareHandler[] | MiddlewareHandler ? RouteMiddlewareParams<R>["env"] & E : E, P, I, R extends {
|
|
174
180
|
responses: {
|
|
175
181
|
[statusCode: number]: {
|
|
176
182
|
content: {
|
|
@@ -186,11 +192,11 @@ declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath e
|
|
|
186
192
|
};
|
|
187
193
|
};
|
|
188
194
|
};
|
|
189
|
-
} ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined> | undefined) => OpenAPIHono<E, S & ToSchema<R[
|
|
190
|
-
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject
|
|
191
|
-
getOpenAPI31Document: (config: OpenAPIObjectConfig) => openapi3_ts_oas31.OpenAPIObject
|
|
192
|
-
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<
|
|
193
|
-
doc31: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<
|
|
195
|
+
} ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], MergePath<BasePath, P>, I, RouteConfigToTypedResponse<R>>, BasePath>;
|
|
196
|
+
getOpenAPIDocument: (config: OpenAPIObjectConfig) => ReturnType<(config: _asteasolutions_zod_to_openapi_dist_v3_0_openapi_generator.OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject>;
|
|
197
|
+
getOpenAPI31Document: (config: OpenAPIObjectConfig) => ReturnType<(config: _asteasolutions_zod_to_openapi_dist_v3_1_openapi_generator.OpenAPIObjectConfigV31) => openapi3_ts_oas31.OpenAPIObject>;
|
|
198
|
+
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
199
|
+
doc31: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
|
194
200
|
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): OpenAPIHono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>;
|
|
195
201
|
route<SubPath extends string>(path: SubPath): Hono<E, RemoveBlankRecord<S>, BasePath>;
|
|
196
202
|
basePath<SubPath extends string>(path: SubPath): OpenAPIHono<E, S, MergePath<BasePath, SubPath>>;
|
|
@@ -199,7 +205,7 @@ type RoutingPath<P extends string> = P extends `${infer Head}/{${infer Param}}${
|
|
|
199
205
|
declare const createRoute: <P extends string, R extends Omit<RouteConfig, "path"> & {
|
|
200
206
|
path: P;
|
|
201
207
|
}>(routeConfig: R) => R & {
|
|
202
|
-
getRoutingPath(): RoutingPath<R[
|
|
208
|
+
getRoutingPath(): RoutingPath<R["path"]>;
|
|
203
209
|
};
|
|
204
210
|
|
|
205
211
|
export { type DeepSimplify, type Hook, type MiddlewareToHandlerType, type OfHandlerType, OpenAPIHono, type OpenAPIHonoOptions, type OpenAPIObjectConfigure, type RouteConfig, type RouteConfigToEnv, type RouteConfigToTypedResponse, type RouteHandler, type RouteHook, createRoute };
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
1
|
// src/index.ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
extendZodWithOpenApi
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
var import_url = require("hono/utils/url");
|
|
33
|
-
var import_zod = require("zod");
|
|
34
|
-
var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
2
|
+
import {
|
|
3
|
+
OpenAPIRegistry,
|
|
4
|
+
OpenApiGeneratorV3,
|
|
5
|
+
OpenApiGeneratorV31,
|
|
6
|
+
extendZodWithOpenApi
|
|
7
|
+
} from "@asteasolutions/zod-to-openapi";
|
|
8
|
+
import { zValidator } from "@hono/zod-validator";
|
|
9
|
+
import { Hono } from "hono";
|
|
10
|
+
import { mergePath } from "hono/utils/url";
|
|
11
|
+
import { ZodType, z } from "zod";
|
|
12
|
+
var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
35
13
|
openAPIRegistry;
|
|
36
14
|
defaultHook;
|
|
37
15
|
constructor(init) {
|
|
38
16
|
super(init);
|
|
39
|
-
this.openAPIRegistry = new
|
|
17
|
+
this.openAPIRegistry = new OpenAPIRegistry();
|
|
40
18
|
this.defaultHook = init?.defaultHook;
|
|
41
19
|
}
|
|
42
20
|
/**
|
|
@@ -76,19 +54,19 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
76
54
|
}
|
|
77
55
|
const validators = [];
|
|
78
56
|
if (route.request?.query) {
|
|
79
|
-
const validator =
|
|
57
|
+
const validator = zValidator("query", route.request.query, hook);
|
|
80
58
|
validators.push(validator);
|
|
81
59
|
}
|
|
82
60
|
if (route.request?.params) {
|
|
83
|
-
const validator =
|
|
61
|
+
const validator = zValidator("param", route.request.params, hook);
|
|
84
62
|
validators.push(validator);
|
|
85
63
|
}
|
|
86
64
|
if (route.request?.headers) {
|
|
87
|
-
const validator =
|
|
65
|
+
const validator = zValidator("header", route.request.headers, hook);
|
|
88
66
|
validators.push(validator);
|
|
89
67
|
}
|
|
90
68
|
if (route.request?.cookies) {
|
|
91
|
-
const validator =
|
|
69
|
+
const validator = zValidator("cookie", route.request.cookies, hook);
|
|
92
70
|
validators.push(validator);
|
|
93
71
|
}
|
|
94
72
|
const bodyContent = route.request?.body?.content;
|
|
@@ -98,11 +76,11 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
98
76
|
continue;
|
|
99
77
|
}
|
|
100
78
|
const schema = bodyContent[mediaType]["schema"];
|
|
101
|
-
if (!(schema instanceof
|
|
79
|
+
if (!(schema instanceof ZodType)) {
|
|
102
80
|
continue;
|
|
103
81
|
}
|
|
104
82
|
if (isJSONContentType(mediaType)) {
|
|
105
|
-
const validator =
|
|
83
|
+
const validator = zValidator("json", schema, hook);
|
|
106
84
|
if (route.request?.body?.required) {
|
|
107
85
|
validators.push(validator);
|
|
108
86
|
} else {
|
|
@@ -119,7 +97,7 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
119
97
|
}
|
|
120
98
|
}
|
|
121
99
|
if (isFormContentType(mediaType)) {
|
|
122
|
-
const validator =
|
|
100
|
+
const validator = zValidator("form", schema, hook);
|
|
123
101
|
if (route.request?.body?.required) {
|
|
124
102
|
validators.push(validator);
|
|
125
103
|
} else {
|
|
@@ -148,12 +126,12 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
148
126
|
return this;
|
|
149
127
|
};
|
|
150
128
|
getOpenAPIDocument = (config) => {
|
|
151
|
-
const generator = new
|
|
129
|
+
const generator = new OpenApiGeneratorV3(this.openAPIRegistry.definitions);
|
|
152
130
|
const document = generator.generateDocument(config);
|
|
153
131
|
return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
|
|
154
132
|
};
|
|
155
133
|
getOpenAPI31Document = (config) => {
|
|
156
|
-
const generator = new
|
|
134
|
+
const generator = new OpenApiGeneratorV31(this.openAPIRegistry.definitions);
|
|
157
135
|
const document = generator.generateDocument(config);
|
|
158
136
|
return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
|
|
159
137
|
};
|
|
@@ -192,7 +170,7 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
192
170
|
case "route":
|
|
193
171
|
return this.openAPIRegistry.registerPath({
|
|
194
172
|
...def.route,
|
|
195
|
-
path:
|
|
173
|
+
path: mergePath(
|
|
196
174
|
pathForOpenAPI,
|
|
197
175
|
// @ts-expect-error _basePath is private
|
|
198
176
|
app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
|
|
@@ -202,7 +180,7 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
202
180
|
case "webhook":
|
|
203
181
|
return this.openAPIRegistry.registerWebhook({
|
|
204
182
|
...def.webhook,
|
|
205
|
-
path:
|
|
183
|
+
path: mergePath(
|
|
206
184
|
pathForOpenAPI,
|
|
207
185
|
// @ts-expect-error _basePath is private
|
|
208
186
|
app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
|
|
@@ -237,11 +215,11 @@ var createRoute = (routeConfig) => {
|
|
|
237
215
|
};
|
|
238
216
|
return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
|
|
239
217
|
};
|
|
240
|
-
|
|
218
|
+
extendZodWithOpenApi(z);
|
|
241
219
|
function addBasePathToDocument(document, basePath) {
|
|
242
220
|
const updatedPaths = {};
|
|
243
221
|
Object.keys(document.paths).forEach((path) => {
|
|
244
|
-
updatedPaths[
|
|
222
|
+
updatedPaths[mergePath(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
|
|
245
223
|
});
|
|
246
224
|
return {
|
|
247
225
|
...document,
|
|
@@ -254,10 +232,9 @@ function isJSONContentType(contentType) {
|
|
|
254
232
|
function isFormContentType(contentType) {
|
|
255
233
|
return contentType.startsWith("multipart/form-data") || contentType.startsWith("application/x-www-form-urlencoded");
|
|
256
234
|
}
|
|
257
|
-
|
|
258
|
-
0 && (module.exports = {
|
|
235
|
+
export {
|
|
259
236
|
OpenAPIHono,
|
|
260
237
|
createRoute,
|
|
261
238
|
extendZodWithOpenApi,
|
|
262
239
|
z
|
|
263
|
-
}
|
|
240
|
+
};
|
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/zod-openapi",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"description": "A wrapper class of Hono which supports OpenAPI.",
|
|
5
|
-
"
|
|
6
|
-
"module": "dist/index.
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"publint": "publint",
|
|
15
|
-
"
|
|
12
|
+
"build": "tsup ./src/index.ts",
|
|
13
|
+
"prepack": "yarn build",
|
|
14
|
+
"publint": "attw --pack && publint",
|
|
15
|
+
"typecheck": "tsc -b tsconfig.json",
|
|
16
|
+
"test": "vitest"
|
|
16
17
|
},
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
19
20
|
"import": {
|
|
20
|
-
"types": "./dist/index.d.mts",
|
|
21
|
-
"default": "./dist/index.mjs"
|
|
22
|
-
},
|
|
23
|
-
"require": {
|
|
24
21
|
"types": "./dist/index.d.ts",
|
|
25
22
|
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/index.d.cts",
|
|
26
|
+
"default": "./dist/index.cjs"
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
},
|
|
@@ -33,7 +34,8 @@
|
|
|
33
34
|
},
|
|
34
35
|
"repository": {
|
|
35
36
|
"type": "git",
|
|
36
|
-
"url": "https://github.com/honojs/middleware.git"
|
|
37
|
+
"url": "git+https://github.com/honojs/middleware.git",
|
|
38
|
+
"directory": "packages/zod-openapi"
|
|
37
39
|
},
|
|
38
40
|
"homepage": "https://github.com/honojs/middleware",
|
|
39
41
|
"peerDependencies": {
|
|
@@ -41,20 +43,19 @@
|
|
|
41
43
|
"zod": "3.*"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"vitest": "^1.4.0",
|
|
46
|
+
"@arethetypeswrong/cli": "^0.17.4",
|
|
47
|
+
"publint": "^0.3.9",
|
|
48
|
+
"tsup": "^8.4.0",
|
|
49
|
+
"typescript": "^5.8.2",
|
|
50
|
+
"vitest": "^3.0.8",
|
|
50
51
|
"yaml": "^2.4.3",
|
|
51
52
|
"zod": "^3.22.1"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@asteasolutions/zod-to-openapi": "^7.1.0",
|
|
55
|
-
"@hono/zod-validator": "^0.4.
|
|
56
|
+
"@hono/zod-validator": "^0.4.3"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|
|
58
59
|
"node": ">=16.0.0"
|
|
59
60
|
}
|
|
60
|
-
}
|
|
61
|
+
}
|