@hono/zod-openapi 1.1.1 → 1.1.3
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 +12 -0
- package/dist/index.cjs +13 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @hono/zod-openapi
|
|
2
2
|
|
|
3
|
+
## 1.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1469](https://github.com/honojs/middleware/pull/1469) [`db68e22a9edee796c8692ef84cdc21be79566718`](https://github.com/honojs/middleware/commit/db68e22a9edee796c8692ef84cdc21be79566718) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Remove `SimplifyDeepArray` usage, see https://github.com/honojs/hono/pull/4406
|
|
8
|
+
|
|
9
|
+
## 1.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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.
|
|
14
|
+
|
|
3
15
|
## 1.1.1
|
|
4
16
|
|
|
5
17
|
### 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.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
|
3
3
|
import { MiddlewareHandler, TypedResponse, Env, ValidationTargets, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
4
4
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
5
5
|
import { InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode, StatusCode } from 'hono/utils/http-status';
|
|
6
|
-
import {
|
|
6
|
+
import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
7
7
|
import { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
8
8
|
import { OpenAPIObject as OpenAPIObject$1 } from 'openapi3-ts/oas31';
|
|
9
9
|
import { ZodType, z, ZodError } from 'zod';
|
|
@@ -23,7 +23,7 @@ type RequestTypes = {
|
|
|
23
23
|
};
|
|
24
24
|
type IsJson<T> = T extends string ? T extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? 'json' : never : never : never;
|
|
25
25
|
type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
|
|
26
|
-
type ReturnJsonOrTextOrResponse<ContentType, Content, Status extends keyof StatusCodeRangeDefinitions | StatusCode> = ContentType extends string ? ContentType extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? TypedResponse<
|
|
26
|
+
type ReturnJsonOrTextOrResponse<ContentType, Content, Status extends keyof StatusCodeRangeDefinitions | StatusCode> = ContentType extends string ? ContentType extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? TypedResponse<JSONParsed<Content>, ExtractStatusCode<Status>, 'json'> : never : ContentType extends `text/plain${infer _Rest}` ? TypedResponse<Content, ExtractStatusCode<Status>, 'text'> : Response : never;
|
|
27
27
|
type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
|
|
28
28
|
type HasUndefined<T> = undefined extends T ? true : false;
|
|
29
29
|
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends keyof ValidationTargets> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends ZodType ? {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
|
3
3
|
import { MiddlewareHandler, TypedResponse, Env, ValidationTargets, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
4
4
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
5
5
|
import { InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode, StatusCode } from 'hono/utils/http-status';
|
|
6
|
-
import {
|
|
6
|
+
import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
7
7
|
import { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
8
8
|
import { OpenAPIObject as OpenAPIObject$1 } from 'openapi3-ts/oas31';
|
|
9
9
|
import { ZodType, z, ZodError } from 'zod';
|
|
@@ -23,7 +23,7 @@ type RequestTypes = {
|
|
|
23
23
|
};
|
|
24
24
|
type IsJson<T> = T extends string ? T extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? 'json' : never : never : never;
|
|
25
25
|
type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
|
|
26
|
-
type ReturnJsonOrTextOrResponse<ContentType, Content, Status extends keyof StatusCodeRangeDefinitions | StatusCode> = ContentType extends string ? ContentType extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? TypedResponse<
|
|
26
|
+
type ReturnJsonOrTextOrResponse<ContentType, Content, Status extends keyof StatusCodeRangeDefinitions | StatusCode> = ContentType extends string ? ContentType extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` ? TypedResponse<JSONParsed<Content>, ExtractStatusCode<Status>, 'json'> : never : ContentType extends `text/plain${infer _Rest}` ? TypedResponse<Content, ExtractStatusCode<Status>, 'text'> : Response : never;
|
|
27
27
|
type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
|
|
28
28
|
type HasUndefined<T> = undefined extends T ? true : false;
|
|
29
29
|
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends keyof ValidationTargets> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends ZodType ? {
|
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)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/zod-openapi",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A wrapper class of Hono which supports OpenAPI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
50
|
-
"hono": "^4.8
|
|
50
|
+
"hono": "^4.9.8",
|
|
51
51
|
"publint": "^0.3.9",
|
|
52
52
|
"tsup": "^8.5.0",
|
|
53
53
|
"typescript": "^5.8.2",
|