@hono/zod-openapi 0.9.0 → 0.9.1
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 +21 -4
- package/dist/index.d.ts +21 -4
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
|
-
import { RouteConfig, OpenAPIRegistry, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi';
|
|
3
|
+
import { RouteConfig, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi';
|
|
4
4
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
5
|
import { Env, Input, Handler, Context, Schema, Hono, ToSchema, TypedResponse } from 'hono';
|
|
6
6
|
import { MergeSchemaPath, MergePath } from 'hono/types';
|
|
@@ -55,19 +55,36 @@ type Hook<T, E extends Env, P extends string, O> = (result: {
|
|
|
55
55
|
error: ZodError;
|
|
56
56
|
}, c: Context<E, P>) => TypedResponse<O> | Promise<TypedResponse<T>> | Response | Promise<Response> | void;
|
|
57
57
|
type ConvertPathType<T extends string> = T extends `${infer Start}/{${infer Param}}${infer Rest}` ? `${Start}/:${Param}${ConvertPathType<Rest>}` : T;
|
|
58
|
-
type
|
|
58
|
+
type HandlerTypedResponse<O> = TypedResponse<O> | Promise<TypedResponse<O>>;
|
|
59
|
+
type HandlerAllResponse<O> = Response | Promise<Response> | TypedResponse<O> | Promise<TypedResponse<O>>;
|
|
59
60
|
type OpenAPIHonoOptions<E extends Env> = {
|
|
60
61
|
defaultHook?: Hook<any, E, any, any>;
|
|
61
62
|
};
|
|
62
63
|
type HonoInit<E extends Env> = ConstructorParameters<typeof Hono>[0] & OpenAPIHonoOptions<E>;
|
|
63
|
-
type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I,
|
|
64
|
+
type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I, R extends {
|
|
65
|
+
responses: {
|
|
66
|
+
[statusCode: string]: {
|
|
67
|
+
content: {
|
|
68
|
+
[mediaType: string]: ZodMediaTypeObject;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
} ? HandlerTypedResponse<OutputType<R>> : HandlerAllResponse<OutputType<R>>>;
|
|
64
73
|
type RouteHook<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Hook<I, E, P, OutputType<R>>;
|
|
65
74
|
type OpenAPIObjectConfigure<E extends Env, P extends string> = OpenAPIObjectConfig | ((context: Context<E, P>) => OpenAPIObjectConfig);
|
|
66
75
|
declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
|
|
67
76
|
openAPIRegistry: OpenAPIRegistry;
|
|
68
77
|
defaultHook?: OpenAPIHonoOptions<E>['defaultHook'];
|
|
69
78
|
constructor(init?: HonoInit<E>);
|
|
70
|
-
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeBase<R, "headers", "header"> & InputTypeBase<R, "cookies", "cookie"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I,
|
|
79
|
+
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeBase<R, "headers", "header"> & InputTypeBase<R, "cookies", "cookie"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, R extends {
|
|
80
|
+
responses: {
|
|
81
|
+
[statusCode: string]: {
|
|
82
|
+
content: {
|
|
83
|
+
[mediaType: string]: ZodMediaTypeObject;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
} ? HandlerTypedResponse<OutputType<R>> : HandlerAllResponse<OutputType<R>>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
|
|
71
88
|
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject;
|
|
72
89
|
getOpenAPI31Document: (config: OpenAPIObjectConfig) => openapi3_ts_oas31.OpenAPIObject;
|
|
73
90
|
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
3
|
-
import { RouteConfig, OpenAPIRegistry, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi';
|
|
3
|
+
import { RouteConfig, ZodMediaTypeObject, OpenAPIRegistry, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi';
|
|
4
4
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
5
5
|
import { Env, Input, Handler, Context, Schema, Hono, ToSchema, TypedResponse } from 'hono';
|
|
6
6
|
import { MergeSchemaPath, MergePath } from 'hono/types';
|
|
@@ -55,19 +55,36 @@ type Hook<T, E extends Env, P extends string, O> = (result: {
|
|
|
55
55
|
error: ZodError;
|
|
56
56
|
}, c: Context<E, P>) => TypedResponse<O> | Promise<TypedResponse<T>> | Response | Promise<Response> | void;
|
|
57
57
|
type ConvertPathType<T extends string> = T extends `${infer Start}/{${infer Param}}${infer Rest}` ? `${Start}/:${Param}${ConvertPathType<Rest>}` : T;
|
|
58
|
-
type
|
|
58
|
+
type HandlerTypedResponse<O> = TypedResponse<O> | Promise<TypedResponse<O>>;
|
|
59
|
+
type HandlerAllResponse<O> = Response | Promise<Response> | TypedResponse<O> | Promise<TypedResponse<O>>;
|
|
59
60
|
type OpenAPIHonoOptions<E extends Env> = {
|
|
60
61
|
defaultHook?: Hook<any, E, any, any>;
|
|
61
62
|
};
|
|
62
63
|
type HonoInit<E extends Env> = ConstructorParameters<typeof Hono>[0] & OpenAPIHonoOptions<E>;
|
|
63
|
-
type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I,
|
|
64
|
+
type RouteHandler<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Handler<E, P, I, R extends {
|
|
65
|
+
responses: {
|
|
66
|
+
[statusCode: string]: {
|
|
67
|
+
content: {
|
|
68
|
+
[mediaType: string]: ZodMediaTypeObject;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
} ? HandlerTypedResponse<OutputType<R>> : HandlerAllResponse<OutputType<R>>>;
|
|
64
73
|
type RouteHook<R extends RouteConfig, E extends Env = Env, I extends Input = InputTypeParam<R> & InputTypeQuery<R> & InputTypeHeader<R> & InputTypeCookie<R> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R['path']>> = Hook<I, E, P, OutputType<R>>;
|
|
65
74
|
type OpenAPIObjectConfigure<E extends Env, P extends string> = OpenAPIObjectConfig | ((context: Context<E, P>) => OpenAPIObjectConfig);
|
|
66
75
|
declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
|
|
67
76
|
openAPIRegistry: OpenAPIRegistry;
|
|
68
77
|
defaultHook?: OpenAPIHonoOptions<E>['defaultHook'];
|
|
69
78
|
constructor(init?: HonoInit<E>);
|
|
70
|
-
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeBase<R, "headers", "header"> & InputTypeBase<R, "cookies", "cookie"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I,
|
|
79
|
+
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeBase<R, "headers", "header"> & InputTypeBase<R, "cookies", "cookie"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, R extends {
|
|
80
|
+
responses: {
|
|
81
|
+
[statusCode: string]: {
|
|
82
|
+
content: {
|
|
83
|
+
[mediaType: string]: ZodMediaTypeObject;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
} ? HandlerTypedResponse<OutputType<R>> : HandlerAllResponse<OutputType<R>>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => OpenAPIHono<E, S & ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
|
|
71
88
|
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject;
|
|
72
89
|
getOpenAPI31Document: (config: OpenAPIObjectConfig) => openapi3_ts_oas31.OpenAPIObject;
|
|
73
90
|
doc: <P extends string>(path: P, configure: OpenAPIObjectConfigure<E, P>) => OpenAPIHono<E, S & ToSchema<"get", P, {}, {}>, BasePath>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/zod-openapi",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A wrapper class of Hono which supports OpenAPI.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/honojs/middleware",
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"hono": ">=3.
|
|
41
|
+
"hono": ">=3.11.1",
|
|
42
42
|
"zod": "3.*"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@hono/zod-validator": "^0.1.11",
|
|
46
|
-
"hono": "^3.
|
|
46
|
+
"hono": "^3.11.1",
|
|
47
47
|
"zod": "^3.22.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=16.0.0"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|