@hono/zod-openapi 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hono/zod-openapi
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1639](https://github.com/honojs/middleware/pull/1639) [`32bc133a58c2a3a79fe386f542eb71fdc5722931`](https://github.com/honojs/middleware/commit/32bc133a58c2a3a79fe386f542eb71fdc5722931) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: introduce `$` and `HonoToOpenAPIHono`
8
+
9
+ ## 1.1.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1637](https://github.com/honojs/middleware/pull/1637) [`64cc1d9b103194d826e8d559104c1191672741a1`](https://github.com/honojs/middleware/commit/64cc1d9b103194d826e8d559104c1191672741a1) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: return `OpenAPIHono` from onError and onNotFound
14
+
3
15
  ## 1.1.5
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -400,6 +400,29 @@ const client = hc<typeof appRoutes>('http://localhost:8787/')
400
400
 
401
401
  ## Tips
402
402
 
403
+ ### Type utilities
404
+
405
+ Methods like `get()`, `post()`, `use()`, etc. return `Hono` type instead of `OpenAPIHono`. This can cause issues when you need the `OpenAPIHono` type. Use the `$()` function to convert the instance back to `OpenAPIHono` type:
406
+
407
+ ```ts
408
+ import { OpenAPIHono, $ } from '@hono/zod-openapi'
409
+
410
+ const app = $(new OpenAPIHono().use(middleware))
411
+ app.openapi(route, handler)
412
+ ```
413
+
414
+ You can also use the `HonoToOpenAPIHono` utility type to convert the return type at the type level:
415
+
416
+ ```ts
417
+ import type { HonoToOpenAPIHono } from '@hono/zod-openapi'
418
+
419
+ const app = new OpenAPIHono()
420
+ const result = app.get('/hello', (c) => c.json({ message: 'Hello' }))
421
+
422
+ // `result` is Hono type, convert it to OpenAPIHono
423
+ type MyApp = HonoToOpenAPIHono<typeof result>
424
+ ```
425
+
403
426
  ### How to register components
404
427
 
405
428
  You can register components to the registry as follows:
package/dist/index.cjs CHANGED
@@ -1,284 +1,269 @@
1
- "use strict";
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  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
8
  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;
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
17
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
19
22
 
20
- // src/index.ts
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");
23
+ //#endregion
24
+ let __asteasolutions_zod_to_openapi = require("@asteasolutions/zod-to-openapi");
25
+ __asteasolutions_zod_to_openapi = __toESM(__asteasolutions_zod_to_openapi);
26
+ let __hono_zod_validator = require("@hono/zod-validator");
27
+ __hono_zod_validator = __toESM(__hono_zod_validator);
28
+ let hono = require("hono");
29
+ hono = __toESM(hono);
30
+ let hono_utils_url = require("hono/utils/url");
31
+ hono_utils_url = __toESM(hono_utils_url);
32
+ let zod = require("zod");
33
+ zod = __toESM(zod);
34
34
 
35
- // src/zod-typeguard.ts
35
+ //#region src/zod-typeguard.ts
36
36
  function isObject(x) {
37
- return typeof x === "object" && x !== null;
37
+ return typeof x === "object" && x !== null;
38
38
  }
39
39
  function isZod(x) {
40
- if (!x) return false;
41
- if (!isObject(x)) return false;
42
- return typeof x.parse === "function" && typeof x.safeParse === "function" && typeof x.parseAsync === "function" && typeof x.safeParseAsync === "function";
40
+ if (!x) return false;
41
+ if (!isObject(x)) return false;
42
+ return typeof x.parse === "function" && typeof x.safeParse === "function" && typeof x.parseAsync === "function" && typeof x.safeParseAsync === "function";
43
43
  }
44
44
 
45
- // src/index.ts
46
- var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
47
- openAPIRegistry;
48
- defaultHook;
49
- constructor(init) {
50
- super(init);
51
- this.openAPIRegistry = new import_zod_to_openapi.OpenAPIRegistry();
52
- this.defaultHook = init?.defaultHook;
53
- }
54
- /**
55
- *
56
- * @param {RouteConfig} route - The route definition which you create with `createRoute()`.
57
- * @param {Handler} handler - The handler. If you want to return a JSON object, you should specify the status code with `c.json()`.
58
- * @param {Hook} hook - Optional. The hook method defines what it should do after validation.
59
- * @example
60
- * app.openapi(
61
- * route,
62
- * (c) => {
63
- * // ...
64
- * return c.json(
65
- * {
66
- * age: 20,
67
- * name: 'Young man',
68
- * },
69
- * 200 // You should specify the status code even if it's 200.
70
- * )
71
- * },
72
- * (result, c) => {
73
- * if (!result.success) {
74
- * return c.json(
75
- * {
76
- * code: 400,
77
- * message: 'Custom Message',
78
- * },
79
- * 400
80
- * )
81
- * }
82
- * }
83
- *)
84
- */
85
- openapi = ({ middleware: routeMiddleware, hide, ...route }, handler, hook = this.defaultHook) => {
86
- if (!hide) {
87
- this.openAPIRegistry.registerPath(route);
88
- }
89
- const validators = [];
90
- if (route.request?.query) {
91
- const validator = (0, import_zod_validator.zValidator)("query", route.request.query, hook);
92
- validators.push(validator);
93
- }
94
- if (route.request?.params) {
95
- const validator = (0, import_zod_validator.zValidator)("param", route.request.params, hook);
96
- validators.push(validator);
97
- }
98
- if (route.request?.headers) {
99
- const validator = (0, import_zod_validator.zValidator)("header", route.request.headers, hook);
100
- validators.push(validator);
101
- }
102
- if (route.request?.cookies) {
103
- const validator = (0, import_zod_validator.zValidator)("cookie", route.request.cookies, hook);
104
- validators.push(validator);
105
- }
106
- const bodyContent = route.request?.body?.content;
107
- if (bodyContent) {
108
- for (const mediaType of Object.keys(bodyContent)) {
109
- if (!bodyContent[mediaType]) {
110
- continue;
111
- }
112
- const schema = bodyContent[mediaType]["schema"];
113
- if (!isZod(schema)) {
114
- continue;
115
- }
116
- if (isJSONContentType(mediaType)) {
117
- const validator = (0, import_zod_validator.zValidator)("json", schema, hook);
118
- if (route.request?.body?.required) {
119
- validators.push(validator);
120
- } else {
121
- const mw = async (c, next) => {
122
- if (c.req.header("content-type")) {
123
- if (isJSONContentType(c.req.header("content-type"))) {
124
- return await validator(c, next);
125
- }
126
- }
127
- c.req.addValidatedData("json", {});
128
- await next();
129
- };
130
- validators.push(mw);
131
- }
132
- }
133
- if (isFormContentType(mediaType)) {
134
- const validator = (0, import_zod_validator.zValidator)("form", schema, hook);
135
- if (route.request?.body?.required) {
136
- validators.push(validator);
137
- } else {
138
- const mw = async (c, next) => {
139
- if (c.req.header("content-type")) {
140
- if (isFormContentType(c.req.header("content-type"))) {
141
- return await validator(c, next);
142
- }
143
- }
144
- c.req.addValidatedData("form", {});
145
- await next();
146
- };
147
- validators.push(mw);
148
- }
149
- }
150
- }
151
- }
152
- const middleware = routeMiddleware ? Array.isArray(routeMiddleware) ? routeMiddleware : [routeMiddleware] : [];
153
- this.on(
154
- [route.method],
155
- route.path.replaceAll(/\/{(.+?)}/g, "/:$1"),
156
- ...middleware,
157
- ...validators,
158
- handler
159
- );
160
- return this;
161
- };
162
- getOpenAPIDocument = (objectConfig, generatorConfig) => {
163
- const generator = new import_zod_to_openapi.OpenApiGeneratorV3(this.openAPIRegistry.definitions, generatorConfig);
164
- const document = generator.generateDocument(objectConfig);
165
- return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
166
- };
167
- getOpenAPI31Document = (objectConfig, generatorConfig) => {
168
- const generator = new import_zod_to_openapi.OpenApiGeneratorV31(this.openAPIRegistry.definitions, generatorConfig);
169
- const document = generator.generateDocument(objectConfig);
170
- return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
171
- };
172
- doc = (path, configureObject, configureGenerator) => {
173
- return this.get(path, (c) => {
174
- const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
175
- const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
176
- try {
177
- const document = this.getOpenAPIDocument(objectConfig, generatorConfig);
178
- return c.json(document);
179
- } catch (e) {
180
- return c.json(e, 500);
181
- }
182
- });
183
- };
184
- doc31 = (path, configureObject, configureGenerator) => {
185
- return this.get(path, (c) => {
186
- const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
187
- const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
188
- try {
189
- const document = this.getOpenAPI31Document(objectConfig, generatorConfig);
190
- return c.json(document);
191
- } catch (e) {
192
- return c.json(e, 500);
193
- }
194
- });
195
- };
196
- route(path, app) {
197
- const pathForOpenAPI = path.replaceAll(/:([^\/]+)/g, "{$1}");
198
- super.route(path, app);
199
- if (!(app instanceof _OpenAPIHono)) {
200
- return this;
201
- }
202
- app.openAPIRegistry.definitions.forEach((def) => {
203
- switch (def.type) {
204
- case "component":
205
- return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component);
206
- case "route": {
207
- this.openAPIRegistry.registerPath({
208
- ...def.route,
209
- path: (0, import_url.mergePath)(
210
- pathForOpenAPI,
211
- // @ts-expect-error _basePath is private
212
- app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
213
- def.route.path
214
- )
215
- });
216
- return;
217
- }
218
- case "webhook": {
219
- this.openAPIRegistry.registerWebhook({
220
- ...def.webhook,
221
- path: (0, import_url.mergePath)(
222
- pathForOpenAPI,
223
- // @ts-expect-error _basePath is private
224
- app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"),
225
- def.webhook.path
226
- )
227
- });
228
- return;
229
- }
230
- case "schema":
231
- return this.openAPIRegistry.register(
232
- (0, import_zod_to_openapi.getOpenApiMetadata)(def.schema)._internal?.refId,
233
- def.schema
234
- );
235
- case "parameter":
236
- return this.openAPIRegistry.registerParameter(
237
- (0, import_zod_to_openapi.getOpenApiMetadata)(def.schema)._internal?.refId,
238
- def.schema
239
- );
240
- default: {
241
- const errorIfNotExhaustive = def;
242
- throw new Error(`Unknown registry type: ${errorIfNotExhaustive}`);
243
- }
244
- }
245
- });
246
- return this;
247
- }
248
- basePath(path) {
249
- return new _OpenAPIHono({ ...super.basePath(path), defaultHook: this.defaultHook });
250
- }
45
+ //#endregion
46
+ //#region src/index.ts
47
+ /**
48
+ * Converts a Hono instance to OpenAPIHono type.
49
+ * Use this function to restore the OpenAPIHono type after chaining methods like `get`, `post`, `use`, etc.
50
+ * @example
51
+ * ```ts
52
+ * import { OpenAPIHono, $ } from '@hono/zod-openapi'
53
+ *
54
+ * const app = $(
55
+ * new OpenAPIHono().use(middleware)
56
+ * )
57
+ * app.openapi(route, handler)
58
+ * ```
59
+ */
60
+ const $ = (app) => {
61
+ return app;
62
+ };
63
+ var OpenAPIHono = class OpenAPIHono extends hono.Hono {
64
+ openAPIRegistry;
65
+ defaultHook;
66
+ constructor(init) {
67
+ super(init);
68
+ this.openAPIRegistry = new __asteasolutions_zod_to_openapi.OpenAPIRegistry();
69
+ this.defaultHook = init === null || init === void 0 ? void 0 : init.defaultHook;
70
+ }
71
+ /**
72
+ *
73
+ * @param {RouteConfig} route - The route definition which you create with `createRoute()`.
74
+ * @param {Handler} handler - The handler. If you want to return a JSON object, you should specify the status code with `c.json()`.
75
+ * @param {Hook} hook - Optional. The hook method defines what it should do after validation.
76
+ * @example
77
+ * app.openapi(
78
+ * route,
79
+ * (c) => {
80
+ * // ...
81
+ * return c.json(
82
+ * {
83
+ * age: 20,
84
+ * name: 'Young man',
85
+ * },
86
+ * 200 // You should specify the status code even if it's 200.
87
+ * )
88
+ * },
89
+ * (result, c) => {
90
+ * if (!result.success) {
91
+ * return c.json(
92
+ * {
93
+ * code: 400,
94
+ * message: 'Custom Message',
95
+ * },
96
+ * 400
97
+ * )
98
+ * }
99
+ * }
100
+ *)
101
+ */
102
+ openapi = ({ middleware: routeMiddleware, hide,...route }, handler, hook = this.defaultHook) => {
103
+ var _route$request, _route$request2, _route$request3, _route$request4, _route$request5;
104
+ if (!hide) this.openAPIRegistry.registerPath(route);
105
+ const validators = [];
106
+ if ((_route$request = route.request) === null || _route$request === void 0 ? void 0 : _route$request.query) {
107
+ const validator = (0, __hono_zod_validator.zValidator)("query", route.request.query, hook);
108
+ validators.push(validator);
109
+ }
110
+ if ((_route$request2 = route.request) === null || _route$request2 === void 0 ? void 0 : _route$request2.params) {
111
+ const validator = (0, __hono_zod_validator.zValidator)("param", route.request.params, hook);
112
+ validators.push(validator);
113
+ }
114
+ if ((_route$request3 = route.request) === null || _route$request3 === void 0 ? void 0 : _route$request3.headers) {
115
+ const validator = (0, __hono_zod_validator.zValidator)("header", route.request.headers, hook);
116
+ validators.push(validator);
117
+ }
118
+ if ((_route$request4 = route.request) === null || _route$request4 === void 0 ? void 0 : _route$request4.cookies) {
119
+ const validator = (0, __hono_zod_validator.zValidator)("cookie", route.request.cookies, hook);
120
+ validators.push(validator);
121
+ }
122
+ 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;
123
+ if (bodyContent) for (const mediaType of Object.keys(bodyContent)) {
124
+ if (!bodyContent[mediaType]) continue;
125
+ const schema = bodyContent[mediaType]["schema"];
126
+ if (!isZod(schema)) continue;
127
+ if (isJSONContentType(mediaType)) {
128
+ var _route$request6;
129
+ const validator = (0, __hono_zod_validator.zValidator)("json", schema, hook);
130
+ 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);
131
+ else {
132
+ const mw = async (c, next) => {
133
+ if (c.req.header("content-type")) {
134
+ if (isJSONContentType(c.req.header("content-type"))) return await validator(c, next);
135
+ }
136
+ c.req.addValidatedData("json", {});
137
+ await next();
138
+ };
139
+ validators.push(mw);
140
+ }
141
+ }
142
+ if (isFormContentType(mediaType)) {
143
+ var _route$request7;
144
+ const validator = (0, __hono_zod_validator.zValidator)("form", schema, hook);
145
+ 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);
146
+ else {
147
+ const mw = async (c, next) => {
148
+ if (c.req.header("content-type")) {
149
+ if (isFormContentType(c.req.header("content-type"))) {
150
+ await validator(c, next);
151
+ return;
152
+ }
153
+ }
154
+ c.req.addValidatedData("form", {});
155
+ await next();
156
+ };
157
+ validators.push(mw);
158
+ }
159
+ }
160
+ }
161
+ const middleware = routeMiddleware ? Array.isArray(routeMiddleware) ? routeMiddleware : [routeMiddleware] : [];
162
+ this.on([route.method], [route.path.replaceAll(/\/{(.+?)}/g, "/:$1")], ...middleware, ...validators, handler);
163
+ return this;
164
+ };
165
+ getOpenAPIDocument = (objectConfig, generatorConfig) => {
166
+ const document = new __asteasolutions_zod_to_openapi.OpenApiGeneratorV3(this.openAPIRegistry.definitions, generatorConfig).generateDocument(objectConfig);
167
+ return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
168
+ };
169
+ getOpenAPI31Document = (objectConfig, generatorConfig) => {
170
+ const document = new __asteasolutions_zod_to_openapi.OpenApiGeneratorV31(this.openAPIRegistry.definitions, generatorConfig).generateDocument(objectConfig);
171
+ return this._basePath ? addBasePathToDocument(document, this._basePath) : document;
172
+ };
173
+ doc = (path, configureObject, configureGenerator) => {
174
+ return this.get(path, (c) => {
175
+ const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
176
+ const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
177
+ try {
178
+ const document = this.getOpenAPIDocument(objectConfig, generatorConfig);
179
+ return c.json(document);
180
+ } catch (e) {
181
+ return c.json(e, 500);
182
+ }
183
+ });
184
+ };
185
+ doc31 = (path, configureObject, configureGenerator) => {
186
+ return this.get(path, (c) => {
187
+ const objectConfig = typeof configureObject === "function" ? configureObject(c) : configureObject;
188
+ const generatorConfig = typeof configureGenerator === "function" ? configureGenerator(c) : configureGenerator;
189
+ try {
190
+ const document = this.getOpenAPI31Document(objectConfig, generatorConfig);
191
+ return c.json(document);
192
+ } catch (e) {
193
+ return c.json(e, 500);
194
+ }
195
+ });
196
+ };
197
+ route(path, app) {
198
+ const pathForOpenAPI = path.replaceAll(/:([^\/]+)/g, "{$1}");
199
+ super.route(path, app);
200
+ if (!(app instanceof OpenAPIHono)) return this;
201
+ app.openAPIRegistry.definitions.forEach((def) => {
202
+ switch (def.type) {
203
+ case "component": return this.openAPIRegistry.registerComponent(def.componentType, def.name, def.component);
204
+ case "route":
205
+ this.openAPIRegistry.registerPath({
206
+ ...def.route,
207
+ path: (0, hono_utils_url.mergePath)(pathForOpenAPI, app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"), def.route.path)
208
+ });
209
+ return;
210
+ case "webhook":
211
+ this.openAPIRegistry.registerWebhook({
212
+ ...def.webhook,
213
+ path: (0, hono_utils_url.mergePath)(pathForOpenAPI, app._basePath.replaceAll(/:([^\/]+)/g, "{$1}"), def.webhook.path)
214
+ });
215
+ return;
216
+ case "schema":
217
+ var _getOpenApiMetadata$_;
218
+ return this.openAPIRegistry.register((_getOpenApiMetadata$_ = (0, __asteasolutions_zod_to_openapi.getOpenApiMetadata)(def.schema)._internal) === null || _getOpenApiMetadata$_ === void 0 ? void 0 : _getOpenApiMetadata$_.refId, def.schema);
219
+ case "parameter":
220
+ var _getOpenApiMetadata$_2;
221
+ return this.openAPIRegistry.registerParameter((_getOpenApiMetadata$_2 = (0, __asteasolutions_zod_to_openapi.getOpenApiMetadata)(def.schema)._internal) === null || _getOpenApiMetadata$_2 === void 0 ? void 0 : _getOpenApiMetadata$_2.refId, def.schema);
222
+ default: {
223
+ const errorIfNotExhaustive = def;
224
+ throw new Error(`Unknown registry type: ${errorIfNotExhaustive}`);
225
+ }
226
+ }
227
+ });
228
+ return this;
229
+ }
230
+ basePath(path) {
231
+ return new OpenAPIHono({
232
+ ...super.basePath(path),
233
+ defaultHook: this.defaultHook
234
+ });
235
+ }
251
236
  };
252
- var createRoute = (routeConfig) => {
253
- const route = {
254
- ...routeConfig,
255
- getRoutingPath() {
256
- return routeConfig.path.replaceAll(/\/{(.+?)}/g, "/:$1");
257
- }
258
- };
259
- return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
237
+ const createRoute = (routeConfig) => {
238
+ const route = {
239
+ ...routeConfig,
240
+ getRoutingPath() {
241
+ return routeConfig.path.replaceAll(/\/{(.+?)}/g, "/:$1");
242
+ }
243
+ };
244
+ return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
260
245
  };
261
- (0, import_zod_to_openapi.extendZodWithOpenApi)(import_zod.z);
246
+ (0, __asteasolutions_zod_to_openapi.extendZodWithOpenApi)(zod.z);
262
247
  function addBasePathToDocument(document, basePath) {
263
- const updatedPaths = {};
264
- Object.keys(document.paths).forEach((path) => {
265
- updatedPaths[(0, import_url.mergePath)(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
266
- });
267
- return {
268
- ...document,
269
- paths: updatedPaths
270
- };
248
+ const updatedPaths = {};
249
+ Object.keys(document.paths).forEach((path) => {
250
+ updatedPaths[(0, hono_utils_url.mergePath)(basePath.replaceAll(/:([^\/]+)/g, "{$1}"), path)] = document.paths[path];
251
+ });
252
+ return {
253
+ ...document,
254
+ paths: updatedPaths
255
+ };
271
256
  }
272
257
  function isJSONContentType(contentType) {
273
- return /^application\/([a-z-\.]+\+)?json/.test(contentType);
258
+ return /^application\/([a-z-\.]+\+)?json/.test(contentType);
274
259
  }
275
260
  function isFormContentType(contentType) {
276
- return contentType.startsWith("multipart/form-data") || contentType.startsWith("application/x-www-form-urlencoded");
261
+ return contentType.startsWith("multipart/form-data") || contentType.startsWith("application/x-www-form-urlencoded");
277
262
  }
278
- // Annotate the CommonJS export names for ESM import in node:
279
- 0 && (module.exports = {
280
- OpenAPIHono,
281
- createRoute,
282
- extendZodWithOpenApi,
283
- z
284
- });
263
+
264
+ //#endregion
265
+ exports.$ = $;
266
+ exports.OpenAPIHono = OpenAPIHono;
267
+ exports.createRoute = createRoute;
268
+ exports.extendZodWithOpenApi = __asteasolutions_zod_to_openapi.extendZodWithOpenApi;
269
+ exports.z = zod.z;