@hono/zod-openapi 1.1.1 → 1.1.2
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 +6 -0
- package/dist/index.cjs +13 -1
- package/dist/index.js +14 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hono/zod-openapi
|
|
2
2
|
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1465](https://github.com/honojs/middleware/pull/1465) [`5eddc2c0fb7991357ef958c1a5eae9714e0139a8`](https://github.com/honojs/middleware/commit/5eddc2c0fb7991357ef958c1a5eae9714e0139a8) Thanks [@eric-poitras](https://github.com/eric-poitras)! - Use a typeguard for zod to avoid issues when bundling with esbuild.
|
|
8
|
+
|
|
3
9
|
## 1.1.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,18 @@ var import_zod_validator = require("@hono/zod-validator");
|
|
|
31
31
|
var import_hono = require("hono");
|
|
32
32
|
var import_url = require("hono/utils/url");
|
|
33
33
|
var import_zod = require("zod");
|
|
34
|
+
|
|
35
|
+
// src/zod-typeguard.ts
|
|
36
|
+
function isObject(x) {
|
|
37
|
+
return typeof x === "object" && x !== null;
|
|
38
|
+
}
|
|
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";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/index.ts
|
|
34
46
|
var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
35
47
|
openAPIRegistry;
|
|
36
48
|
defaultHook;
|
|
@@ -98,7 +110,7 @@ var OpenAPIHono = class _OpenAPIHono extends import_hono.Hono {
|
|
|
98
110
|
continue;
|
|
99
111
|
}
|
|
100
112
|
const schema = bodyContent[mediaType]["schema"];
|
|
101
|
-
if (!(schema
|
|
113
|
+
if (!isZod(schema)) {
|
|
102
114
|
continue;
|
|
103
115
|
}
|
|
104
116
|
if (isJSONContentType(mediaType)) {
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,19 @@ import {
|
|
|
9
9
|
import { zValidator } from "@hono/zod-validator";
|
|
10
10
|
import { Hono } from "hono";
|
|
11
11
|
import { mergePath } from "hono/utils/url";
|
|
12
|
-
import {
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
// src/zod-typeguard.ts
|
|
15
|
+
function isObject(x) {
|
|
16
|
+
return typeof x === "object" && x !== null;
|
|
17
|
+
}
|
|
18
|
+
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";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/index.ts
|
|
13
25
|
var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
14
26
|
openAPIRegistry;
|
|
15
27
|
defaultHook;
|
|
@@ -77,7 +89,7 @@ var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
|
77
89
|
continue;
|
|
78
90
|
}
|
|
79
91
|
const schema = bodyContent[mediaType]["schema"];
|
|
80
|
-
if (!(schema
|
|
92
|
+
if (!isZod(schema)) {
|
|
81
93
|
continue;
|
|
82
94
|
}
|
|
83
95
|
if (isJSONContentType(mediaType)) {
|