@hono/zod-openapi 0.14.2 → 0.14.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/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -2
- package/dist/index.mjs +3 -3
- package/package.json +1 -2
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,9 @@ import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodR
|
|
|
4
4
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
5
|
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
6
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
|
+
import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
7
8
|
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status';
|
|
8
|
-
import {
|
|
9
|
-
import { ZodError, AnyZodObject, z, ZodSchema, ZodType } from 'zod';
|
|
9
|
+
import { ZodError, ZodType, z, ZodSchema } from 'zod';
|
|
10
10
|
export { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
type MaybePromise<T> = Promise<T> | T;
|
|
@@ -15,15 +15,15 @@ type RouteConfig = RouteConfig$1 & {
|
|
|
15
15
|
};
|
|
16
16
|
type RequestTypes = {
|
|
17
17
|
body?: ZodRequestBody;
|
|
18
|
-
params?:
|
|
19
|
-
query?:
|
|
20
|
-
cookies?:
|
|
21
|
-
headers?:
|
|
18
|
+
params?: ZodType;
|
|
19
|
+
query?: ZodType;
|
|
20
|
+
cookies?: ZodType;
|
|
21
|
+
headers?: ZodType | ZodType[];
|
|
22
22
|
};
|
|
23
23
|
type IsJson<T> = T extends string ? T extends `application/json${infer _Rest}` ? 'json' : never : never;
|
|
24
24
|
type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
|
|
25
25
|
type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
|
|
26
|
-
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends string> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends
|
|
26
|
+
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends string> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends ZodType ? {
|
|
27
27
|
in: {
|
|
28
28
|
[K in Type]: z.input<RequestPart<R, Part>>;
|
|
29
29
|
};
|
|
@@ -64,7 +64,7 @@ type StatusCodeRangeDefinitions = {
|
|
|
64
64
|
type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode;
|
|
65
65
|
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T;
|
|
66
66
|
type RouteConfigToTypedResponse<R extends RouteConfig> = {
|
|
67
|
-
[Status in keyof R['responses'] & RouteConfigStatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, ExtractStatusCode<Status>, string> : TypedResponse<ExtractContent<R['responses'][Status]['content']
|
|
67
|
+
[Status in keyof R['responses'] & RouteConfigStatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, ExtractStatusCode<Status>, string> : TypedResponse<JSONParsed<ExtractContent<R['responses'][Status]['content']>>, ExtractStatusCode<Status>, 'json'>;
|
|
68
68
|
}[keyof R['responses'] & RouteConfigStatusCode];
|
|
69
69
|
type Hook<T, E extends Env, P extends string, R> = (result: {
|
|
70
70
|
success: true;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { RouteConfig as RouteConfig$1, ZodMediaTypeObject, OpenAPIRegistry, ZodR
|
|
|
4
4
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
5
|
import { MiddlewareHandler, TypedResponse, Env, Context, Input, Handler, Schema, Hono, ToSchema } from 'hono';
|
|
6
6
|
import { MergePath, MergeSchemaPath } from 'hono/types';
|
|
7
|
+
import { JSONParsed, RemoveBlankRecord } from 'hono/utils/types';
|
|
7
8
|
import { StatusCode, InfoStatusCode, SuccessStatusCode, RedirectStatusCode, ClientErrorStatusCode, ServerErrorStatusCode } from 'hono/utils/http-status';
|
|
8
|
-
import {
|
|
9
|
-
import { ZodError, AnyZodObject, z, ZodSchema, ZodType } from 'zod';
|
|
9
|
+
import { ZodError, ZodType, z, ZodSchema } from 'zod';
|
|
10
10
|
export { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
type MaybePromise<T> = Promise<T> | T;
|
|
@@ -15,15 +15,15 @@ type RouteConfig = RouteConfig$1 & {
|
|
|
15
15
|
};
|
|
16
16
|
type RequestTypes = {
|
|
17
17
|
body?: ZodRequestBody;
|
|
18
|
-
params?:
|
|
19
|
-
query?:
|
|
20
|
-
cookies?:
|
|
21
|
-
headers?:
|
|
18
|
+
params?: ZodType;
|
|
19
|
+
query?: ZodType;
|
|
20
|
+
cookies?: ZodType;
|
|
21
|
+
headers?: ZodType | ZodType[];
|
|
22
22
|
};
|
|
23
23
|
type IsJson<T> = T extends string ? T extends `application/json${infer _Rest}` ? 'json' : never : never;
|
|
24
24
|
type IsForm<T> = T extends string ? T extends `multipart/form-data${infer _Rest}` | `application/x-www-form-urlencoded${infer _Rest}` ? 'form' : never : never;
|
|
25
25
|
type RequestPart<R extends RouteConfig, Part extends string> = Part extends keyof R['request'] ? R['request'][Part] : {};
|
|
26
|
-
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends string> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends
|
|
26
|
+
type InputTypeBase<R extends RouteConfig, Part extends string, Type extends string> = R['request'] extends RequestTypes ? RequestPart<R, Part> extends ZodType ? {
|
|
27
27
|
in: {
|
|
28
28
|
[K in Type]: z.input<RequestPart<R, Part>>;
|
|
29
29
|
};
|
|
@@ -64,7 +64,7 @@ type StatusCodeRangeDefinitions = {
|
|
|
64
64
|
type RouteConfigStatusCode = keyof StatusCodeRangeDefinitions | StatusCode;
|
|
65
65
|
type ExtractStatusCode<T extends RouteConfigStatusCode> = T extends keyof StatusCodeRangeDefinitions ? StatusCodeRangeDefinitions[T] : T;
|
|
66
66
|
type RouteConfigToTypedResponse<R extends RouteConfig> = {
|
|
67
|
-
[Status in keyof R['responses'] & RouteConfigStatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, ExtractStatusCode<Status>, string> : TypedResponse<ExtractContent<R['responses'][Status]['content']
|
|
67
|
+
[Status in keyof R['responses'] & RouteConfigStatusCode]: IsJson<keyof R['responses'][Status]['content']> extends never ? TypedResponse<{}, ExtractStatusCode<Status>, string> : TypedResponse<JSONParsed<ExtractContent<R['responses'][Status]['content']>>, ExtractStatusCode<Status>, 'json'>;
|
|
68
68
|
}[keyof R['responses'] & RouteConfigStatusCode];
|
|
69
69
|
type Hook<T, E extends Env, P extends string, R> = (result: {
|
|
70
70
|
success: true;
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,6 @@ __export(src_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(src_exports);
|
|
28
28
|
var import_zod_to_openapi = require("@asteasolutions/zod-to-openapi");
|
|
29
|
-
var import_zod_to_openapi2 = require("@asteasolutions/zod-to-openapi");
|
|
30
29
|
var import_zod_validator = require("@hono/zod-validator");
|
|
31
30
|
var import_hono = require("hono");
|
|
32
31
|
var import_url = require("hono/utils/url");
|
|
@@ -199,7 +198,7 @@ var createRoute = (routeConfig) => {
|
|
|
199
198
|
};
|
|
200
199
|
return Object.defineProperty(route, "getRoutingPath", { enumerable: false });
|
|
201
200
|
};
|
|
202
|
-
(0,
|
|
201
|
+
(0, import_zod_to_openapi.extendZodWithOpenApi)(import_zod.z);
|
|
203
202
|
// Annotate the CommonJS export names for ESM import in node:
|
|
204
203
|
0 && (module.exports = {
|
|
205
204
|
OpenAPIHono,
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import {
|
|
3
|
+
OpenAPIRegistry,
|
|
3
4
|
OpenApiGeneratorV3,
|
|
4
5
|
OpenApiGeneratorV31,
|
|
5
|
-
|
|
6
|
+
extendZodWithOpenApi
|
|
6
7
|
} from "@asteasolutions/zod-to-openapi";
|
|
7
|
-
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
|
|
8
8
|
import { zValidator } from "@hono/zod-validator";
|
|
9
9
|
import { Hono } from "hono";
|
|
10
10
|
import { mergePath } from "hono/utils/url";
|
|
11
|
-
import {
|
|
11
|
+
import { ZodType, z } from "zod";
|
|
12
12
|
var OpenAPIHono = class _OpenAPIHono extends Hono {
|
|
13
13
|
openAPIRegistry;
|
|
14
14
|
defaultHook;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/zod-openapi",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "A wrapper class of Hono which supports OpenAPI.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@cloudflare/workers-types": "^4.20240117.0",
|
|
45
45
|
"hono": "^4.3.6",
|
|
46
46
|
"jest": "^29.7.0",
|
|
47
|
-
"openapi3-ts": "^4.1.2",
|
|
48
47
|
"tsup": "^8.0.1",
|
|
49
48
|
"typescript": "^5.4.4",
|
|
50
49
|
"vitest": "^1.4.0",
|