@hono/zod-openapi 0.1.1 → 0.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/README.md +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ import { createRoute } from '@hono/zod-openapi'
|
|
|
63
63
|
|
|
64
64
|
const route = createRoute({
|
|
65
65
|
method: 'get',
|
|
66
|
-
path: '/users
|
|
66
|
+
path: '/users/{id}',
|
|
67
67
|
request: {
|
|
68
68
|
params: ParamsSchema,
|
|
69
69
|
},
|
|
@@ -134,7 +134,7 @@ Then, add the error response:
|
|
|
134
134
|
```ts
|
|
135
135
|
const route = createRoute({
|
|
136
136
|
method: 'get',
|
|
137
|
-
path: '/users
|
|
137
|
+
path: '/users/{id}',
|
|
138
138
|
request: {
|
|
139
139
|
params: ParamsSchema,
|
|
140
140
|
},
|
|
@@ -159,7 +159,7 @@ app.openapi(
|
|
|
159
159
|
(c) => {
|
|
160
160
|
const { id } = c.req.valid('param')
|
|
161
161
|
return c.jsonT({
|
|
162
|
-
id
|
|
162
|
+
id,
|
|
163
163
|
age: 20,
|
|
164
164
|
name: 'Ultra-man',
|
|
165
165
|
})
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
2
2
|
import { RouteConfig, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi';
|
|
3
3
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
4
|
-
import { Env, Hono, Input, Handler,
|
|
4
|
+
import { Env, Schema, Hono, Input, Handler, ToSchema, Context, TypedResponse } from 'hono';
|
|
5
5
|
import { AnyZodObject, z, ZodSchema, ZodError, ZodType } from 'zod';
|
|
6
6
|
export { z } from 'zod';
|
|
7
7
|
|
|
@@ -48,10 +48,10 @@ type Hook<T, E extends Env, P extends string, O> = (result: {
|
|
|
48
48
|
error: ZodError;
|
|
49
49
|
}, c: Context<E, P>) => TypedResponse<O> | Promise<TypedResponse<T>> | void;
|
|
50
50
|
type ConvertPathType<T extends string> = T extends `${infer _}/{${infer Param}}${infer _}` ? `/:${Param}` : T;
|
|
51
|
-
declare class OpenAPIHono<E extends Env = Env, S = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
|
|
51
|
+
declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
|
|
52
52
|
#private;
|
|
53
53
|
constructor();
|
|
54
|
-
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E,
|
|
54
|
+
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E, ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
|
|
55
55
|
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject;
|
|
56
56
|
doc: (path: string, config: OpenAPIObjectConfig) => void;
|
|
57
57
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
2
2
|
import { RouteConfig, ZodRequestBody, ZodContentObject, ResponseConfig } from '@asteasolutions/zod-to-openapi';
|
|
3
3
|
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator';
|
|
4
|
-
import { Env, Hono, Input, Handler,
|
|
4
|
+
import { Env, Schema, Hono, Input, Handler, ToSchema, Context, TypedResponse } from 'hono';
|
|
5
5
|
import { AnyZodObject, z, ZodSchema, ZodError, ZodType } from 'zod';
|
|
6
6
|
export { z } from 'zod';
|
|
7
7
|
|
|
@@ -48,10 +48,10 @@ type Hook<T, E extends Env, P extends string, O> = (result: {
|
|
|
48
48
|
error: ZodError;
|
|
49
49
|
}, c: Context<E, P>) => TypedResponse<O> | Promise<TypedResponse<T>> | void;
|
|
50
50
|
type ConvertPathType<T extends string> = T extends `${infer _}/{${infer Param}}${infer _}` ? `/:${Param}` : T;
|
|
51
|
-
declare class OpenAPIHono<E extends Env = Env, S = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
|
|
51
|
+
declare class OpenAPIHono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> extends Hono<E, S, BasePath> {
|
|
52
52
|
#private;
|
|
53
53
|
constructor();
|
|
54
|
-
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E,
|
|
54
|
+
openapi: <R extends RouteConfig, I extends Input = InputTypeBase<R, "params", "param"> & InputTypeBase<R, "query", "query"> & InputTypeForm<R> & InputTypeJson<R>, P extends string = ConvertPathType<R["path"]>>(route: R, handler: Handler<E, P, I, OutputType<R>>, hook?: Hook<I, E, P, OutputType<R>> | undefined) => Hono<E, ToSchema<R["method"], P, I["in"], OutputType<R>>, BasePath>;
|
|
55
55
|
getOpenAPIDocument: (config: OpenAPIObjectConfig) => openapi3_ts_oas30.OpenAPIObject;
|
|
56
56
|
doc: (path: string, config: OpenAPIObjectConfig) => void;
|
|
57
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/zod-openapi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A wrapper class of Hono which supports OpenAPI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"zod": "3.*"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"hono": "^3.4
|
|
34
|
+
"hono": "^3.5.4",
|
|
35
35
|
"zod": "^3.22.1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@asteasolutions/zod-to-openapi": "^5.5.0",
|
|
39
|
-
"@hono/zod-validator": "^0.1.
|
|
39
|
+
"@hono/zod-validator": "^0.1.8"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=16.0.0"
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|