@hono/zod-openapi 1.1.5 → 1.1.6

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/dist/index.js CHANGED
@@ -1,262 +1,222 @@
1
- // src/index.ts
2
- import {
3
- OpenAPIRegistry,
4
- OpenApiGeneratorV3,
5
- OpenApiGeneratorV31,
6
- extendZodWithOpenApi,
7
- getOpenApiMetadata
8
- } from "@asteasolutions/zod-to-openapi";
1
+ import { OpenAPIRegistry, OpenApiGeneratorV3, OpenApiGeneratorV31, extendZodWithOpenApi, getOpenApiMetadata } from "@asteasolutions/zod-to-openapi";
9
2
  import { zValidator } from "@hono/zod-validator";
10
3
  import { Hono } from "hono";
11
4
  import { mergePath } from "hono/utils/url";
12
5
  import { z } from "zod";
13
6
 
14
- // src/zod-typeguard.ts
7
+ //#region src/zod-typeguard.ts
15
8
  function isObject(x) {
16
- return typeof x === "object" && x !== null;
9
+ return typeof x === "object" && x !== null;
17
10
  }
18
11
  function isZod(x) {
19
- if (!x) return false;
20
- if (!isObject(x)) return false;
21
- return typeof x.parse === "function" && typeof x.safeParse === "function" && typeof x.parseAsync === "function" && typeof x.safeParseAsync === "function";
12
+ if (!x) return false;
13
+ if (!isObject(x)) return false;
14
+ return typeof x.parse === "function" && typeof x.safeParse === "function" && typeof x.parseAsync === "function" && typeof x.safeParseAsync === "function";
22
15
  }
23
16
 
24
- // src/index.ts
25
- var OpenAPIHono = class _OpenAPIHono extends Hono {
26
- openAPIRegistry;
27
- defaultHook;
28
- constructor(init) {
29
- super(init);
30
- this.openAPIRegistry = new OpenAPIRegistry();
31
- this.defaultHook = init?.defaultHook;
32
- }
33
- /**
34
- *
35
- * @param {RouteConfig} route - The route definition which you create with `createRoute()`.
36
- * @param {Handler} handler - The handler. If you want to return a JSON object, you should specify the status code with `c.json()`.
37
- * @param {Hook} hook - Optional. The hook method defines what it should do after validation.
38
- * @example
39
- * app.openapi(
40
- * route,
41
- * (c) => {
42
- * // ...
43
- * return c.json(
44
- * {
45
- * age: 20,
46
- * name: 'Young man',
47
- * },
48
- * 200 // You should specify the status code even if it's 200.
49
- * )
50
- * },
51
- * (result, c) => {
52
- * if (!result.success) {
53
- * return c.json(
54
- * {
55
- * code: 400,
56
- * message: 'Custom Message',
57
- * },
58
- * 400
59
- * )
60
- * }
61
- * }
62
- *)
63
- */
64
- openapi = ({ middleware: routeMiddleware, hide, ...route }, handler, hook = this.defaultHook) => {
65
- if (!hide) {
66
- this.openAPIRegistry.registerPath(route);
67
- }
68
- const validators = [];
69
- if (route.request?.query) {
70
- const validator = zValidator("query", route.request.query, hook);
71
- validators.push(validator);
72
- }
73
- if (route.request?.params) {
74
- const validator = zValidator("param", route.request.params, hook);
75
- validators.push(validator);
76
- }
77
- if (route.request?.headers) {
78
- const validator = zValidator("header", route.request.headers, hook);
79
- validators.push(validator);
80
- }
81
- if (route.request?.cookies) {
82
- const validator = zValidator("cookie", route.request.cookies, hook);
83
- validators.push(validator);
84
- }
85
- const bodyContent = route.request?.body?.content;
86
- if (bodyContent) {
87
- for (const mediaType of Object.keys(bodyContent)) {
88
- if (!bodyContent[mediaType]) {
89
- continue;
90
- }
91
- const schema = bodyContent[mediaType]["schema"];
92
- if (!isZod(schema)) {
93
- continue;
94
- }
95
- if (isJSONContentType(mediaType)) {
96
- const validator = zValidator("json", schema, hook);
97
- if (route.request?.body?.required) {
98
- validators.push(validator);
99
- } else {
100
- const mw = async (c, next) => {
101
- if (c.req.header("content-type")) {
102
- if (isJSONContentType(c.req.header("content-type"))) {
103
- return await validator(c, next);
104
- }
105
- }
106
- c.req.addValidatedData("json", {});
107
- await next();
108
- };
109
- validators.push(mw);
110
- }
111
- }
112
- if (isFormContentType(mediaType)) {
113
- const validator = zValidator("form", schema, hook);
114
- if (route.request?.body?.required) {
115
- validators.push(validator);
116
- } else {
117
- const mw = async (c, next) => {
118
- if (c.req.header("content-type")) {
119
- if (isFormContentType(c.req.header("content-type"))) {
120
- return await validator(c, next);
121
- }
122
- }
123
- c.req.addValidatedData("form", {});
124
- await next();
125
- };
126
- validators.push(mw);
127
- }
128
- }
129
- }
130
- }
131
- const middleware = routeMiddleware ? Array.isArray(routeMiddleware) ? routeMiddleware : [routeMiddleware] : [];
132
- this.on(
133
- [route.method],
134
- route.path.replaceAll(/\/{(.+?)}/g, "/:$1"),
135
- ...middleware,
136
- ...validators,
137
- handler
138
- );
139
- return this;
140
- };
141
- getOpenAPIDocument = (objectConfig, generatorConfig) => {
142
- const generator = new OpenApiGeneratorV3(this.openAPIRegistry.definitions, generatorConfig);
143
- const document = generator.generateDocument(objectConfig);
144
- return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
145
- };
146
- getOpenAPI31Document = (objectConfig, generatorConfig) => {
147
- const generator = new OpenApiGeneratorV31(this.openAPIRegistry.definitions, generatorConfig);
148
- const document = generator.generateDocument(objectConfig);
149
- return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
150
- };
151
- doc = (path, configureObject, configureGenerator) => {
152
- return this.get(path, (c) => {
153
- const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
154
- const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
155
- try {
156
- const document = this.getOpenAPIDocument(objectConfig, generatorConfig);
157
- return c.json(document);
158
- } catch (e) {
159
- return c.json(e, 500);
160
- }
161
- });
162
- };
163
- doc31 = (path, configureObject, configureGenerator) => {
164
- return this.get(path, (c) => {
165
- const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
166
- const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
167
- try {
168
- const document = this.getOpenAPI31Document(objectConfig, generatorConfig);
169
- return c.json(document);
170
- } catch (e) {
171
- return c.json(e, 500);
172
- }
173
- });
174
- };
175
- route(path, app) {
176
- const pathForOpenAPI = path.replaceAll(/:([^\/]+)/g, "{$1}");
177
- super.route(path, app);
178
- if (!(app instanceof _OpenAPIHono)) {
179
- return this;
180
- }
181
- app.openAPIRegistry.definitions.forEach((def) => {
182
- switch (def.type) {
183
- case "component":
184
- return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component);
185
- case "route": {
186
- this.openAPIRegistry.registerPath({
187
- ...def.route,
188
- path: mergePath(
189
- pathForOpenAPI,
190
- // @ts-expect-error _basePath is private
191
- app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
192
- def.route.path
193
- )
194
- });
195
- return;
196
- }
197
- case "webhook": {
198
- this.openAPIRegistry.registerWebhook({
199
- ...def.webhook,
200
- path: mergePath(
201
- pathForOpenAPI,
202
- // @ts-expect-error _basePath is private
203
- app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
204
- def.webhook.path
205
- )
206
- });
207
- return;
208
- }
209
- case "schema":
210
- return this.openAPIRegistry.register(
211
- getOpenApiMetadata(def.schema)._internal?.refId,
212
- def.schema
213
- );
214
- case "parameter":
215
- return this.openAPIRegistry.registerParameter(
216
- getOpenApiMetadata(def.schema)._internal?.refId,
217
- def.schema
218
- );
219
- default: {
220
- const errorIfNotExhaustive = def;
221
- throw new Error(`Unknown registry type: ${errorIfNotExhaustive}`);
222
- }
223
- }
224
- });
225
- return this;
226
- }
227
- basePath(path) {
228
- return new _OpenAPIHono({ ...super.basePath(path), defaultHook: this.defaultHook });
229
- }
17
+ //#endregion
18
+ //#region src/index.ts
19
+ var OpenAPIHono = class OpenAPIHono extends Hono {
20
+ openAPIRegistry;
21
+ defaultHook;
22
+ constructor(init) {
23
+ super(init);
24
+ this.openAPIRegistry = new OpenAPIRegistry();
25
+ this.defaultHook = init === null || init === void 0 ? void 0 : init.defaultHook;
26
+ }
27
+ /**
28
+ *
29
+ * @param {RouteConfig} route - The route definition which you create with `createRoute()`.
30
+ * @param {Handler} handler - The handler. If you want to return a JSON object, you should specify the status code with `c.json()`.
31
+ * @param {Hook} hook - Optional. The hook method defines what it should do after validation.
32
+ * @example
33
+ * app.openapi(
34
+ * route,
35
+ * (c) => {
36
+ * // ...
37
+ * return c.json(
38
+ * {
39
+ * age: 20,
40
+ * name: 'Young man',
41
+ * },
42
+ * 200 // You should specify the status code even if it's 200.
43
+ * )
44
+ * },
45
+ * (result, c) => {
46
+ * if (!result.success) {
47
+ * return c.json(
48
+ * {
49
+ * code: 400,
50
+ * message: 'Custom Message',
51
+ * },
52
+ * 400
53
+ * )
54
+ * }
55
+ * }
56
+ *)
57
+ */
58
+ openapi = ({ middleware: routeMiddleware, hide,...route }, handler, hook = this.defaultHook) => {
59
+ var _route$request, _route$request2, _route$request3, _route$request4, _route$request5;
60
+ if (!hide) this.openAPIRegistry.registerPath(route);
61
+ const validators = [];
62
+ if ((_route$request = route.request) === null || _route$request === void 0 ? void 0 : _route$request.query) {
63
+ const validator = zValidator("query", route.request.query, hook);
64
+ validators.push(validator);
65
+ }
66
+ if ((_route$request2 = route.request) === null || _route$request2 === void 0 ? void 0 : _route$request2.params) {
67
+ const validator = zValidator("param", route.request.params, hook);
68
+ validators.push(validator);
69
+ }
70
+ if ((_route$request3 = route.request) === null || _route$request3 === void 0 ? void 0 : _route$request3.headers) {
71
+ const validator = zValidator("header", route.request.headers, hook);
72
+ validators.push(validator);
73
+ }
74
+ if ((_route$request4 = route.request) === null || _route$request4 === void 0 ? void 0 : _route$request4.cookies) {
75
+ const validator = zValidator("cookie", route.request.cookies, hook);
76
+ validators.push(validator);
77
+ }
78
+ const bodyContent = (_route$request5 = route.request) === null || _route$request5 === void 0 || (_route$request5 = _route$request5.body) === null || _route$request5 === void 0 ? void 0 : _route$request5.content;
79
+ if (bodyContent) for (const mediaType of Object.keys(bodyContent)) {
80
+ if (!bodyContent[mediaType]) continue;
81
+ const schema = bodyContent[mediaType]["schema"];
82
+ if (!isZod(schema)) continue;
83
+ if (isJSONContentType(mediaType)) {
84
+ var _route$request6;
85
+ const validator = zValidator("json", schema, hook);
86
+ if ((_route$request6 = route.request) === null || _route$request6 === void 0 || (_route$request6 = _route$request6.body) === null || _route$request6 === void 0 ? void 0 : _route$request6.required) validators.push(validator);
87
+ else {
88
+ const mw = async (c, next) => {
89
+ if (c.req.header("content-type")) {
90
+ if (isJSONContentType(c.req.header("content-type"))) return await validator(c, next);
91
+ }
92
+ c.req.addValidatedData("json", {});
93
+ await next();
94
+ };
95
+ validators.push(mw);
96
+ }
97
+ }
98
+ if (isFormContentType(mediaType)) {
99
+ var _route$request7;
100
+ const validator = zValidator("form", schema, hook);
101
+ if ((_route$request7 = route.request) === null || _route$request7 === void 0 || (_route$request7 = _route$request7.body) === null || _route$request7 === void 0 ? void 0 : _route$request7.required) validators.push(validator);
102
+ else {
103
+ const mw = async (c, next) => {
104
+ if (c.req.header("content-type")) {
105
+ if (isFormContentType(c.req.header("content-type"))) {
106
+ await validator(c, next);
107
+ return;
108
+ }
109
+ }
110
+ c.req.addValidatedData("form", {});
111
+ await next();
112
+ };
113
+ validators.push(mw);
114
+ }
115
+ }
116
+ }
117
+ const middleware = routeMiddleware ? Array.isArray(routeMiddleware) ? routeMiddleware : [routeMiddleware] : [];
118
+ this.on([route.method], [route.path.replaceAll(/\/{(.+?)}/g, "/:$1")], ...middleware, ...validators, handler);
119
+ return this;
120
+ };
121
+ getOpenAPIDocument = (objectConfig, generatorConfig) => {
122
+ const document = new OpenApiGeneratorV3(this.openAPIRegistry.definitions, generatorConfig).generateDocument(objectConfig);
123
+ return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
124
+ };
125
+ getOpenAPI31Document = (objectConfig, generatorConfig) => {
126
+ const document = new OpenApiGeneratorV31(this.openAPIRegistry.definitions, generatorConfig).generateDocument(objectConfig);
127
+ return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
128
+ };
129
+ doc = (path, configureObject, configureGenerator) => {
130
+ return this.get(path, (c) => {
131
+ const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
132
+ const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
133
+ try {
134
+ const document = this.getOpenAPIDocument(objectConfig, generatorConfig);
135
+ return c.json(document);
136
+ } catch (e) {
137
+ return c.json(e, 500);
138
+ }
139
+ });
140
+ };
141
+ doc31 = (path, configureObject, configureGenerator) => {
142
+ return this.get(path, (c) => {
143
+ const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
144
+ const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
145
+ try {
146
+ const document = this.getOpenAPI31Document(objectConfig, generatorConfig);
147
+ return c.json(document);
148
+ } catch (e) {
149
+ return c.json(e, 500);
150
+ }
151
+ });
152
+ };
153
+ route(path, app) {
154
+ const pathForOpenAPI = path.replaceAll(/:([^\/]+)/g, "{$1}");
155
+ super.route(path, app);
156
+ if (!(app instanceof OpenAPIHono)) return this;
157
+ app.openAPIRegistry.definitions.forEach((def) => {
158
+ switch (def.type) {
159
+ case "component": return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component);
160
+ case "route":
161
+ this.openAPIRegistry.registerPath({
162
+ ...def.route,
163
+ path: mergePath(pathForOpenAPI, app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"), def.route.path)
164
+ });
165
+ return;
166
+ case "webhook":
167
+ this.openAPIRegistry.registerWebhook({
168
+ ...def.webhook,
169
+ path: mergePath(pathForOpenAPI, app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"), def.webhook.path)
170
+ });
171
+ return;
172
+ case "schema":
173
+ var _getOpenApiMetadata$_;
174
+ return this.openAPIRegistry.register((_getOpenApiMetadata$_ = getOpenApiMetadata(def.schema)._internal) === null || _getOpenApiMetadata$_ === void 0 ? void 0 : _getOpenApiMetadata$_.refId, def.schema);
175
+ case "parameter":
176
+ var _getOpenApiMetadata$_2;
177
+ return this.openAPIRegistry.registerParameter((_getOpenApiMetadata$_2 = getOpenApiMetadata(def.schema)._internal) === null || _getOpenApiMetadata$_2 === void 0 ? void 0 : _getOpenApiMetadata$_2.refId, def.schema);
178
+ default: {
179
+ const errorIfNotExhaustive = def;
180
+ throw new Error(`Unknown registry type: ${errorIfNotExhaustive}`);
181
+ }
182
+ }
183
+ });
184
+ return this;
185
+ }
186
+ basePath(path) {
187
+ return new OpenAPIHono({
188
+ ...super.basePath(path),
189
+ defaultHook: this.defaultHook
190
+ });
191
+ }
230
192
  };
231
- var createRoute = (routeConfig) => {
232
- const route = {
233
- ...routeConfig,
234
- getRoutingPath() {
235
- return routeConfig.path.replaceAll(/\/{(.+?)}/g, "/:$1");
236
- }
237
- };
238
- return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
193
+ const createRoute = (routeConfig) => {
194
+ const route = {
195
+ ...routeConfig,
196
+ getRoutingPath() {
197
+ return routeConfig.path.replaceAll(/\/{(.+?)}/g, "/:$1");
198
+ }
199
+ };
200
+ return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
239
201
  };
240
202
  extendZodWithOpenApi(z);
241
203
  function addBasePathToDocument(document, basePath) {
242
- const updatedPaths = {};
243
- Object.keys(document.paths).forEach((path) => {
244
- updatedPaths[mergePath(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
245
- });
246
- return {
247
- ...document,
248
- paths: updatedPaths
249
- };
204
+ const updatedPaths = {};
205
+ Object.keys(document.paths).forEach((path) => {
206
+ updatedPaths[mergePath(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
207
+ });
208
+ return {
209
+ ...document,
210
+ paths: updatedPaths
211
+ };
250
212
  }
251
213
  function isJSONContentType(contentType) {
252
- return /^application\/([a-z-\.]+\+)?json/.test(contentType);
214
+ return /^application\/([a-z-\.]+\+)?json/.test(contentType);
253
215
  }
254
216
  function isFormContentType(contentType) {
255
- return contentType.startsWith("multipart/form-data") || contentType.startsWith("application/x-www-form-urlencoded");
217
+ return contentType.startsWith("multipart/form-data") || contentType.startsWith("application/x-www-form-urlencoded");
256
218
  }
257
- export {
258
- OpenAPIHono,
259
- createRoute,
260
- extendZodWithOpenApi,
261
- z
262
- };
219
+
220
+ //#endregion
221
+ export { OpenAPIHono, createRoute, extendZodWithOpenApi, z };
222
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["validators: MiddlewareHandler[]","mw: MiddlewareHandler","e: any","errorIfNotExhaustive: never","updatedPaths: Record<string, any>"],"sources":["../src/zod-typeguard.ts","../src/index.ts"],"sourcesContent":["import type { ZodType as ZodTypeV3 } from 'zod/v3'\nimport type { ZodType as ZodTypeV4 } from 'zod/v4'\n\nfunction isObject(x: unknown): x is Record<string, unknown> {\n return typeof x === 'object' && x !== null\n}\n\nexport function isZod(x: unknown): x is ZodTypeV3 | ZodTypeV4 {\n if (!x) return false\n if (!isObject(x)) return false\n return (\n typeof x.parse === 'function' &&\n typeof x.safeParse === 'function' &&\n typeof x.parseAsync === 'function' &&\n typeof x.safeParseAsync === 'function'\n )\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n RouteConfig as RouteConfigBase,\n ZodContentObject,\n ZodMediaTypeObject,\n ZodRequestBody,\n} from '@asteasolutions/zod-to-openapi'\nimport {\n OpenAPIRegistry,\n OpenApiGeneratorV3,\n OpenApiGeneratorV31,\n extendZodWithOpenApi,\n getOpenApiMetadata,\n} from '@asteasolutions/zod-to-openapi'\nimport { zValidator } from '@hono/zod-validator'\nimport { Hono } from 'hono'\nimport type {\n Context,\n Env,\n ErrorHandler,\n Handler,\n Input,\n MiddlewareHandler,\n NotFoundHandler,\n Schema,\n ToSchema,\n TypedResponse,\n ValidationTargets,\n} from 'hono'\nimport type { H, MergePath, MergeSchemaPath } from 'hono/types'\nimport type {\n ClientErrorStatusCode,\n InfoStatusCode,\n RedirectStatusCode,\n ServerErrorStatusCode,\n StatusCode,\n SuccessStatusCode,\n} from 'hono/utils/http-status'\nimport type { JSONParsed, RemoveBlankRecord } from 'hono/utils/types'\nimport { mergePath } from 'hono/utils/url'\nimport type { OpenAPIObject } from 'openapi3-ts/oas30'\nimport type { OpenAPIObject as OpenAPIV31bject } from 'openapi3-ts/oas31'\nimport type { ZodType, ZodError } from 'zod'\nimport { z } from 'zod'\nimport { isZod } from './zod-typeguard'\n\ntype MaybePromise<T> = Promise<T> | T\n\nexport type RouteConfig = RouteConfigBase & {\n middleware?: H | H[]\n hide?: boolean\n}\n\ntype RequestTypes = {\n body?: ZodRequestBody\n params?: ZodType\n query?: ZodType\n cookies?: ZodType\n headers?: ZodType | ZodType[]\n}\n\ntype IsJson<T> = T extends string\n ? T extends `application/${infer Start}json${infer _End}`\n ? Start extends '' | `${string}+` | `vnd.${string}+`\n ? 'json'\n : never\n : never\n : never\n\ntype IsForm<T> = T extends string\n ? T extends\n | `multipart/form-data${infer _Rest}`\n | `application/x-www-form-urlencoded${infer _Rest}`\n ? 'form'\n : never\n : never\n\ntype ReturnJsonOrTextOrResponse<\n ContentType,\n Content,\n Status extends keyof StatusCodeRangeDefinitions | StatusCode,\n> = ContentType extends string\n ? ContentType extends `application/${infer Start}json${infer _End}`\n ? Start extends '' | `${string}+` | `vnd.${string}+`\n ? TypedResponse<JSONParsed<Content>, ExtractStatusCode<Status>, 'json'>\n : never\n : ContentType extends `text/plain${infer _Rest}`\n ? TypedResponse<Content, ExtractStatusCode<Status>, 'text'>\n : Response\n : never\n\ntype RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request']\n ? R['request'][Part]\n : {}\n\ntype HasUndefined<T> = undefined extends T ? true : false\n\ntype InputTypeBase<\n R extends RouteConfig,\n Part extends string,\n Type extends keyof ValidationTargets,\n> = R['request'] extends RequestTypes\n ? RequestPart<R, Part> extends ZodType\n ? {\n in: {\n [K in Type]: HasUndefined<ValidationTargets[K]> extends true\n ? {\n [K2 in keyof z.input<RequestPart<R, Part>>]?: z.input<RequestPart<R, Part>>[K2]\n }\n : {\n [K2 in keyof z.input<RequestPart<R, Part>>]: z.input<RequestPart<R, Part>>[K2]\n }\n }\n out: { [K in Type]: z.output<RequestPart<R, Part>> }\n }\n : {}\n : {}\n\ntype InputTypeJson<R extends RouteConfig> = R['request'] extends RequestTypes\n ? R['request']['body'] extends ZodRequestBody\n ? R['request']['body']['content'] extends ZodContentObject\n ? IsJson<keyof R['request']['body']['content']> extends never\n ? {}\n : R['request']['body']['content'][keyof R['request']['body']['content']] extends Record<\n 'schema',\n ZodType<any>\n >\n ? {\n in: {\n json: z.input<\n R['request']['body']['content'][keyof R['request']['body']['content']]['schema']\n >\n }\n out: {\n json: z.output<\n R['request']['body']['content'][keyof R['request']['body']['content']]['schema']\n >\n }\n }\n : {}\n : {}\n : {}\n : {}\n\ntype InputTypeForm<R extends RouteConfig> = R['request'] extends RequestTypes\n ? R['request']['body'] extends ZodRequestBody\n ? R['request']['body']['content'] extends ZodContentObject\n ? IsForm<keyof R['request']['body']['content']> extends never\n ? {}\n : R['request']['body']['content'][keyof R['request']['body']['content']] extends Record<\n 'schema',\n ZodType<any>\n >\n ? {\n in: {\n form: z.input<\n R['request']['body']['content'][keyof R['request']['body']['content']]['schema']\n >\n }\n out: {\n form: z.output<\n R['request']['body']['content'][keyof R['request']['body']['content']]['schema']\n >\n }\n }\n : {}\n : {}\n : {}\n : {}\n\ntype InputTypeParam<R extends RouteConfig> = InputTypeBase<R, 'params', 'param'>\ntype InputTypeQuery<R extends RouteConfig> = InputTypeBase<R, 'query', 'query'>\ntype InputTypeHeader<R extends RouteConfig> = InputTypeBase<R, 'headers', 'header'>\ntype InputTypeCookie<R extends RouteConfig> = InputTypeBase<R, 'cookies', 'cookie'>\n\ntype ExtractContent<T> = T extends {\n [K in keyof T]: infer A\n}\n ? A extends Record<'schema', ZodType>\n ? z.infer<A['schema']>\n : never\n : never\n\ntype StatusCodeRangeDefinitions = {\n '1XX': InfoStatusCode\n '2XX': SuccessStatusCode\n '3XX': RedirectStatusCode\n '4XX': ClientErrorStatusCode\n '5XX': ServerErrorStatusCode\n}\ntype RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode\ntype ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions\n ? StatusCodeRangeDefinitions[T]\n : T\ntype DefinedStatusCodes<R extends RouteConfig> = keyof R['responses'] & RouteConfigStatusCode\nexport type RouteConfigToTypedResponse<R extends RouteConfig> =\n | {\n [Status in DefinedStatusCodes<R>]: R['responses'][Status] extends { content: infer Content }\n ? undefined extends Content\n ? never\n : ReturnJsonOrTextOrResponse<\n keyof R['responses'][Status]['content'],\n ExtractContent<R['responses'][Status]['content']>,\n Status\n >\n : TypedResponse<{}, ExtractStatusCode<Status>, string>\n }[DefinedStatusCodes<R>]\n | ('default' extends keyof R['responses']\n ? R['responses']['default'] extends { content: infer Content }\n ? undefined extends Content\n ? never\n : ReturnJsonOrTextOrResponse<\n keyof Content,\n ExtractContent<Content>,\n Exclude<StatusCode, ExtractStatusCode<DefinedStatusCodes<R>>>\n >\n : TypedResponse<{}, Exclude<StatusCode, ExtractStatusCode<DefinedStatusCodes<R>>>, string>\n : never)\n\nexport type Hook<T, E extends Env, P extends string, R> = (\n result: { target: keyof ValidationTargets } & (\n | {\n success: true\n data: T\n }\n | {\n success: false\n error: ZodError\n }\n ),\n c: Context<E, P>\n) => R\n\ntype ConvertPathType<T extends string> = T extends `${infer Start}/{${infer Param}}${infer Rest}`\n ? `${Start}/:${Param}${ConvertPathType<Rest>}`\n : T\n\nexport type OpenAPIHonoOptions<E extends Env> = {\n defaultHook?: Hook<any, E, any, any>\n}\ntype HonoInit<E extends Env> = ConstructorParameters<typeof Hono>[0] & OpenAPIHonoOptions<E>\n\n/**\n * Turns `T | T[] | undefined` into `T[]`\n */\ntype AsArray<T> = T extends undefined // TODO move to utils?\n ? []\n : T extends any[]\n ? T\n : [T]\n\n/**\n * Like simplify but recursive\n */\nexport type DeepSimplify<T> = {\n // TODO move to utils?\n [KeyType in keyof T]: T[KeyType] extends Record<string, unknown>\n ? DeepSimplify<T[KeyType]>\n : T[KeyType]\n} & {}\n\n/**\n * Helper to infer generics from {@link MiddlewareHandler}\n */\nexport type OfHandlerType<T extends MiddlewareHandler> =\n T extends MiddlewareHandler<infer E, infer P, infer I>\n ? {\n env: E\n path: P\n input: I\n }\n : never\n\n/**\n * Reduce a tuple of middleware handlers into a single\n * handler representing the composition of all\n * handlers.\n */\nexport type MiddlewareToHandlerType<M extends MiddlewareHandler<any, any, any>[]> = M extends [\n infer First,\n infer Second,\n ...infer Rest,\n]\n ? First extends MiddlewareHandler<any, any, any>\n ? Second extends MiddlewareHandler<any, any, any>\n ? Rest extends MiddlewareHandler<any, any, any>[] // Ensure Rest is an array of MiddlewareHandler\n ? MiddlewareToHandlerType<\n [\n MiddlewareHandler<\n DeepSimplify<OfHandlerType<First>['env'] & OfHandlerType<Second>['env']>, // Combine envs\n OfHandlerType<First>['path'], // Keep path from First\n OfHandlerType<First>['input'] // Keep input from First\n >,\n ...Rest,\n ]\n >\n : never\n : never\n : never\n : M extends [infer Last]\n ? Last // Return the last remaining handler in the array\n : MiddlewareHandler<Env>\n\ntype RouteMiddlewareParams<R extends RouteConfig> = OfHandlerType<\n MiddlewareToHandlerType<AsArray<R['middleware']>>\n>\n\nexport type RouteConfigToEnv<R extends RouteConfig> =\n RouteMiddlewareParams<R> extends never ? Env : RouteMiddlewareParams<R>['env']\n\nexport type RouteHandler<\n R extends RouteConfig,\n E extends Env = RouteConfigToEnv<R>,\n I extends Input = InputTypeParam<R> &\n InputTypeQuery<R> &\n InputTypeHeader<R> &\n InputTypeCookie<R> &\n InputTypeForm<R> &\n InputTypeJson<R>,\n P extends string = ConvertPathType<R['path']>,\n> = Handler<\n E,\n P,\n I,\n // If response type is defined, only TypedResponse is allowed.\n R extends {\n responses: {\n [statusCode: number]: {\n content: {\n [mediaType: string]: ZodMediaTypeObject\n }\n }\n }\n }\n ? MaybePromise<RouteConfigToTypedResponse<R>>\n : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response>\n>\n\nexport type RouteHook<\n R extends RouteConfig,\n E extends Env = RouteConfigToEnv<R>,\n I extends Input = InputTypeParam<R> &\n InputTypeQuery<R> &\n InputTypeHeader<R> &\n InputTypeCookie<R> &\n InputTypeForm<R> &\n InputTypeJson<R>,\n P extends string = ConvertPathType<R['path']>,\n> = Hook<\n I,\n E,\n P,\n RouteConfigToTypedResponse<R> | Response | Promise<Response> | void | Promise<void>\n>\n\ntype OpenAPIObjectConfig = Parameters<\n InstanceType<typeof OpenApiGeneratorV3>['generateDocument']\n>[0]\n\nexport type OpenAPIObjectConfigure<E extends Env, P extends string> =\n | OpenAPIObjectConfig\n | ((context: Context<E, P>) => OpenAPIObjectConfig)\n\nexport type OpenAPIGeneratorOptions = ConstructorParameters<typeof OpenApiGeneratorV3>[1]\n\nexport type OpenAPIGeneratorConfigure<E extends Env, P extends string> =\n | OpenAPIGeneratorOptions\n | ((context: Context<E, P>) => OpenAPIGeneratorOptions)\n\nexport class OpenAPIHono<\n E extends Env = Env,\n S extends Schema = {},\n BasePath extends string = '/',\n> extends Hono<E, S, BasePath> {\n openAPIRegistry: OpenAPIRegistry\n defaultHook?: OpenAPIHonoOptions<E>['defaultHook']\n\n constructor(init?: HonoInit<E>) {\n super(init)\n this.openAPIRegistry = new OpenAPIRegistry()\n this.defaultHook = init?.defaultHook\n }\n\n /**\n *\n * @param {RouteConfig} route - The route definition which you create with `createRoute()`.\n * @param {Handler} handler - The handler. If you want to return a JSON object, you should specify the status code with `c.json()`.\n * @param {Hook} hook - Optional. The hook method defines what it should do after validation.\n * @example\n * app.openapi(\n * route,\n * (c) => {\n * // ...\n * return c.json(\n * {\n * age: 20,\n * name: 'Young man',\n * },\n * 200 // You should specify the status code even if it's 200.\n * )\n * },\n * (result, c) => {\n * if (!result.success) {\n * return c.json(\n * {\n * code: 400,\n * message: 'Custom Message',\n * },\n * 400\n * )\n * }\n * }\n *)\n */\n openapi = <\n R extends RouteConfig,\n I extends Input = InputTypeParam<R> &\n InputTypeQuery<R> &\n InputTypeHeader<R> &\n InputTypeCookie<R> &\n InputTypeForm<R> &\n InputTypeJson<R>,\n P extends string = ConvertPathType<R['path']>,\n >(\n { middleware: routeMiddleware, hide, ...route }: R,\n handler: Handler<\n // use the env from the middleware if it's defined\n R['middleware'] extends MiddlewareHandler[] | MiddlewareHandler\n ? RouteMiddlewareParams<R>['env'] & E\n : E,\n P,\n I,\n // If response type is defined, only TypedResponse is allowed.\n R extends {\n responses: {\n [statusCode: number]: {\n content: {\n [mediaType: string]: ZodMediaTypeObject\n }\n }\n }\n }\n ? MaybePromise<RouteConfigToTypedResponse<R>>\n : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response>\n >,\n hook:\n | Hook<\n I,\n E,\n P,\n R extends {\n responses: {\n [statusCode: number]: {\n content: {\n [mediaType: string]: ZodMediaTypeObject\n }\n }\n }\n }\n ? MaybePromise<RouteConfigToTypedResponse<R>> | undefined\n : MaybePromise<RouteConfigToTypedResponse<R>> | MaybePromise<Response> | undefined\n >\n | undefined = this.defaultHook\n ): OpenAPIHono<\n E,\n S & ToSchema<R['method'], MergePath<BasePath, P>, I, RouteConfigToTypedResponse<R>>,\n BasePath\n > => {\n if (!hide) {\n this.openAPIRegistry.registerPath(route)\n }\n\n const validators: MiddlewareHandler[] = []\n\n if (route.request?.query) {\n const validator = zValidator('query', route.request.query as any, hook as any)\n validators.push(validator as any)\n }\n\n if (route.request?.params) {\n const validator = zValidator('param', route.request.params as any, hook as any)\n validators.push(validator as any)\n }\n\n if (route.request?.headers) {\n const validator = zValidator('header', route.request.headers as any, hook as any)\n validators.push(validator as any)\n }\n\n if (route.request?.cookies) {\n const validator = zValidator('cookie', route.request.cookies as any, hook as any)\n validators.push(validator as any)\n }\n\n const bodyContent = route.request?.body?.content\n\n if (bodyContent) {\n for (const mediaType of Object.keys(bodyContent)) {\n if (!bodyContent[mediaType]) {\n continue\n }\n const schema = (bodyContent[mediaType] as ZodMediaTypeObject)['schema']\n if (!isZod(schema)) {\n continue\n }\n if (isJSONContentType(mediaType)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore we can ignore the type error since Zod Validator's types are not used\n const validator = zValidator('json', schema, hook) as MiddlewareHandler\n if (route.request?.body?.required) {\n validators.push(validator)\n } else {\n const mw: MiddlewareHandler = async (c, next) => {\n if (c.req.header('content-type')) {\n if (isJSONContentType(c.req.header('content-type')!)) {\n return await validator(c, next)\n }\n }\n c.req.addValidatedData('json', {})\n await next()\n }\n validators.push(mw)\n }\n }\n if (isFormContentType(mediaType)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore we can ignore the type error since Zod Validator's types are not used\n const validator = zValidator('form', schema, hook) as MiddlewareHandler\n if (route.request?.body?.required) {\n validators.push(validator)\n } else {\n const mw: MiddlewareHandler = async (c, next) => {\n if (c.req.header('content-type')) {\n if (isFormContentType(c.req.header('content-type')!)) {\n await validator(c, next)\n return\n }\n }\n c.req.addValidatedData('form', {})\n await next()\n }\n validators.push(mw)\n }\n }\n }\n }\n\n const middleware = routeMiddleware\n ? Array.isArray(routeMiddleware)\n ? routeMiddleware\n : [routeMiddleware]\n : []\n\n this.on(\n [route.method],\n [route.path.replaceAll(/\\/{(.+?)}/g, '/:$1')],\n ...middleware,\n ...validators,\n handler\n )\n return this\n }\n\n getOpenAPIDocument = (\n objectConfig: OpenAPIObjectConfig,\n generatorConfig?: OpenAPIGeneratorOptions\n ): OpenAPIObject => {\n const generator = new OpenApiGeneratorV3(this.openAPIRegistry.definitions, generatorConfig)\n const document = generator.generateDocument(objectConfig)\n // @ts-expect-error the _basePath is a private property\n return this._basePath ? addBasePathToDocument(document, this._basePath) : document\n }\n\n getOpenAPI31Document = (\n objectConfig: OpenAPIObjectConfig,\n generatorConfig?: OpenAPIGeneratorOptions\n ): OpenAPIV31bject => {\n const generator = new OpenApiGeneratorV31(this.openAPIRegistry.definitions, generatorConfig)\n const document = generator.generateDocument(objectConfig)\n // @ts-expect-error the _basePath is a private property\n return this._basePath ? addBasePathToDocument(document, this._basePath) : document\n }\n\n doc = <P extends string>(\n path: P,\n configureObject: OpenAPIObjectConfigure<E, P>,\n configureGenerator?: OpenAPIGeneratorConfigure<E, P>\n ): OpenAPIHono<E, S & ToSchema<'get', MergePath<BasePath, P>, {}, {}>, BasePath> => {\n return this.get(path, (c) => {\n const objectConfig =\n typeof configureObject === 'function' ? configureObject(c) : configureObject\n const generatorConfig =\n typeof configureGenerator === 'function' ? configureGenerator(c) : configureGenerator\n try {\n const document = this.getOpenAPIDocument(objectConfig, generatorConfig)\n return c.json(document)\n } catch (e: any) {\n return c.json(e, 500)\n }\n }) as any\n }\n\n doc31 = <P extends string>(\n path: P,\n configureObject: OpenAPIObjectConfigure<E, P>,\n configureGenerator?: OpenAPIGeneratorConfigure<E, P>\n ): OpenAPIHono<E, S & ToSchema<'get', MergePath<BasePath, P>, {}, {}>, BasePath> => {\n return this.get(path, (c) => {\n const objectConfig =\n typeof configureObject === 'function' ? configureObject(c) : configureObject\n const generatorConfig =\n typeof configureGenerator === 'function' ? configureGenerator(c) : configureGenerator\n try {\n const document = this.getOpenAPI31Document(objectConfig, generatorConfig)\n return c.json(document)\n } catch (e: any) {\n return c.json(e, 500)\n }\n }) as any\n }\n\n route<\n SubPath extends string,\n SubEnv extends Env,\n SubSchema extends Schema,\n SubBasePath extends string,\n >(\n path: SubPath,\n app: Hono<SubEnv, SubSchema, SubBasePath>\n ): OpenAPIHono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>\n route<SubPath extends string>(path: SubPath): Hono<E, RemoveBlankRecord<S>, BasePath>\n route<\n SubPath extends string,\n SubEnv extends Env,\n SubSchema extends Schema,\n SubBasePath extends string,\n >(\n path: SubPath,\n app?: Hono<SubEnv, SubSchema, SubBasePath>\n ): OpenAPIHono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath> {\n const pathForOpenAPI = path.replaceAll(/:([^\\/]+)/g, '{$1}')\n super.route(path, app as any)\n\n if (!(app instanceof OpenAPIHono)) {\n return this as any\n }\n\n app.openAPIRegistry.definitions.forEach((def) => {\n switch (def.type) {\n case 'component':\n return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component)\n\n case 'route': {\n this.openAPIRegistry.registerPath({\n ...def.route,\n path: mergePath(\n pathForOpenAPI,\n // @ts-expect-error _basePath is private\n app._basePath.replaceAll(/:([^\\/]+)/g, '{$1}'),\n def.route.path\n ),\n })\n return\n }\n\n case 'webhook': {\n this.openAPIRegistry.registerWebhook({\n ...def.webhook,\n path: mergePath(\n pathForOpenAPI,\n // @ts-expect-error _basePath is private\n app._basePath.replaceAll(/:([^\\/]+)/g, '{$1}'),\n def.webhook.path\n ),\n })\n return\n }\n\n case 'schema':\n return this.openAPIRegistry.register(\n getOpenApiMetadata(def.schema)._internal?.refId,\n def.schema\n )\n\n case 'parameter':\n return this.openAPIRegistry.registerParameter(\n getOpenApiMetadata(def.schema)._internal?.refId,\n def.schema\n )\n\n default: {\n const errorIfNotExhaustive: never = def\n throw new Error(`Unknown registry type: ${errorIfNotExhaustive}`)\n }\n }\n })\n\n return this as any\n }\n\n basePath<SubPath extends string>(path: SubPath): OpenAPIHono<E, S, MergePath<BasePath, SubPath>> {\n return new OpenAPIHono({ ...(super.basePath(path) as any), defaultHook: this.defaultHook })\n }\n\n // Type overrides to return OpenAPIHono instead of Hono\n declare onError: (handler: ErrorHandler<E>) => OpenAPIHono<E, S, BasePath>\n declare notFound: (handler: NotFoundHandler<E>) => OpenAPIHono<E, S, BasePath>\n}\n\ntype RoutingPath<P extends string> = P extends `${infer Head}/{${infer Param}}${infer Tail}`\n ? `${Head}/:${Param}${RoutingPath<Tail>}`\n : P\n\nexport const createRoute = <P extends string, R extends Omit<RouteConfig, 'path'> & { path: P }>(\n routeConfig: R\n): R & {\n getRoutingPath(): RoutingPath<R['path']>\n} => {\n const route = {\n ...routeConfig,\n getRoutingPath(): RoutingPath<R['path']> {\n return routeConfig.path.replaceAll(/\\/{(.+?)}/g, '/:$1') as RoutingPath<P>\n },\n }\n return Object.defineProperty(route, 'getRoutingPath', { enumerable: false })\n}\n\nextendZodWithOpenApi(z)\nexport { extendZodWithOpenApi, z }\n\nfunction addBasePathToDocument(document: Record<string, any>, basePath: string) {\n const updatedPaths: Record<string, any> = {}\n\n Object.keys(document.paths).forEach((path) => {\n updatedPaths[mergePath(basePath.replaceAll(/:([^\\/]+)/g, '{$1}'), path)] = document.paths[path]\n })\n\n return {\n ...document,\n paths: updatedPaths,\n }\n}\n\nfunction isJSONContentType(contentType: string) {\n return /^application\\/([a-z-\\.]+\\+)?json/.test(contentType)\n}\n\nfunction isFormContentType(contentType: string) {\n return (\n contentType.startsWith('multipart/form-data') ||\n contentType.startsWith('application/x-www-form-urlencoded')\n )\n}\n"],"mappings":";;;;;;;AAGA,SAAS,SAAS,GAA0C;AAC1D,QAAO,OAAO,MAAM,YAAY,MAAM;;AAGxC,SAAgB,MAAM,GAAwC;AAC5D,KAAI,CAAC,EAAG,QAAO;AACf,KAAI,CAAC,SAAS,EAAE,CAAE,QAAO;AACzB,QACE,OAAO,EAAE,UAAU,cACnB,OAAO,EAAE,cAAc,cACvB,OAAO,EAAE,eAAe,cACxB,OAAO,EAAE,mBAAmB;;;;;ACoWhC,IAAa,cAAb,MAAa,oBAIH,KAAqB;CAC7B;CACA;CAEA,YAAY,MAAoB;AAC9B,QAAM,KAAK;AACX,OAAK,kBAAkB,IAAI,iBAAiB;AAC5C,OAAK,0DAAc,KAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC3B,WAUE,EAAE,YAAY,iBAAiB,KAAM,GAAG,SACxC,SAoBA,OAiBgB,KAAK,gBAKlB;;AACH,MAAI,CAAC,KACH,MAAK,gBAAgB,aAAa,MAAM;EAG1C,MAAMA,aAAkC,EAAE;AAE1C,wBAAI,MAAM,yEAAS,OAAO;GACxB,MAAM,YAAY,WAAW,SAAS,MAAM,QAAQ,OAAc,KAAY;AAC9E,cAAW,KAAK,UAAiB;;AAGnC,yBAAI,MAAM,2EAAS,QAAQ;GACzB,MAAM,YAAY,WAAW,SAAS,MAAM,QAAQ,QAAe,KAAY;AAC/E,cAAW,K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kB;CAC9E,MAAMC,eAAoC,EAAE;AAE5C,QAAO,KAAK,SAAS,MAAM,CAAC,SAAS,SAAS;AAC5C,eAAa,UAAU,SAAS,WAAW,cAAc,OAAO,EAAE,KAAK,IAAI,SAAS,MAAM;GAC1F;AAEF,QAAO;EACL,GAAG;EACH,OAAO;EACR;;AAGH,SAAS,kBAAkB,aAAqB;AAC9C,QAAO,mCAAmC,KAAK,YAAY;;AAG7D,SAAS,kBAAkB,aAAqB;AAC9C,QACE,YAAY,WAAW,sBAAsB,IAC7C,YAAY,WAAW,oCAAoC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/zod-openapi",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "A wrapper class of Hono which supports OpenAPI.",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
@@ -9,11 +9,9 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "build": "tsup ./src/index.ts",
12
+ "build": "tsdown",
13
13
  "format": "prettier --check . --ignore-path ../../.gitignore",
14
14
  "lint": "eslint",
15
- "prepack": "yarn build",
16
- "publint": "attw --pack && publint",
17
15
  "typecheck": "tsc -b tsconfig.json",
18
16
  "test": "vitest",
19
17
  "version:jsr": "yarn version:set $npm_package_version"
@@ -33,7 +31,8 @@
33
31
  "license": "MIT",
34
32
  "publishConfig": {
35
33
  "registry": "https://registry.npmjs.org",
36
- "access": "public"
34
+ "access": "public",
35
+ "provenance": true
37
36
  },
38
37
  "repository": {
39
38
  "type": "git",
@@ -46,18 +45,16 @@
46
45
  "zod": "^4.0.0"
47
46
  },
48
47
  "devDependencies": {
49
- "@arethetypeswrong/cli": "^0.18.2",
50
- "hono": "^4.10.1",
51
- "publint": "^0.3.14",
52
- "tsup": "^8.5.0",
48
+ "hono": "^4.11.1",
49
+ "tsdown": "^0.15.9",
53
50
  "typescript": "^5.8.2",
54
51
  "vitest": "^3.2.4",
55
- "yaml": "^2.8.1",
56
- "zod": "^4.0.5"
52
+ "yaml": "^2.8.2",
53
+ "zod": "^4.1.13"
57
54
  },
58
55
  "dependencies": {
59
56
  "@asteasolutions/zod-to-openapi": "^8.1.0",
60
- "@hono/zod-validator": "^0.7.4",
57
+ "@hono/zod-validator": "^0.7.6",
61
58
  "openapi3-ts": "^4.5.0"
62
59
  },
63
60
  "engines": {