Skip to content

Commit d54096f

Browse files
fix: added types to validation middleware (#171)
* fix: added types to validation middleware * chore: formatted the code
1 parent d835237 commit d54096f

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

src/__tests__/__snapshots__/valibot.test.ts.snap

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,53 @@ exports[`valibot > with metadata 1`] = `
129129
"tags": undefined,
130130
}
131131
`;
132+
133+
exports[`valibot > with transformation 1`] = `
134+
{
135+
"components": {},
136+
"info": {
137+
"description": "Development documentation",
138+
"title": "Hono Documentation",
139+
"version": "0.0.0",
140+
},
141+
"openapi": "3.1.0",
142+
"paths": {
143+
"/": {
144+
"get": {
145+
"description": "This is a test route",
146+
"operationId": "getIndex",
147+
"parameters": [
148+
{
149+
"in": "query",
150+
"name": "names",
151+
"required": true,
152+
"schema": {
153+
"items": {
154+
"type": "string",
155+
},
156+
"type": "array",
157+
},
158+
},
159+
],
160+
"responses": {
161+
"200": {
162+
"content": {
163+
"application/json": {
164+
"schema": {
165+
"type": "string",
166+
},
167+
},
168+
},
169+
"description": "Success",
170+
},
171+
},
172+
"summary": "Test route",
173+
"tags": [
174+
"test",
175+
],
176+
},
177+
},
178+
},
179+
"tags": undefined,
180+
}
181+
`;

src/__tests__/valibot.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe("valibot", () => {
103103
}),
104104
undefined,
105105
{
106-
typeMode: "output",
106+
options: { typeMode: "output" },
107107
},
108108
),
109109
async (c) => {

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ToOpenAPISchemaContext } from "@standard-community/standard-openapi";
12
import type { Context } from "hono";
23
import type { RouterRoute, ValidationTargets } from "hono/types";
34
import type { OpenAPIV3_1 } from "openapi-types";
@@ -12,7 +13,7 @@ export type ResolverReturnType = ReturnType<typeof resolver> & {
1213
* Override the media type of the request body, if not specified, it will be `application/json` for `json` target and `multipart/form-data` for `form` target.
1314
*/
1415
media?: string;
15-
} & { [key: string]: unknown };
16+
} & Partial<ToOpenAPISchemaContext>;
1617
};
1718

1819
export type HandlerUniqueProperty =

0 commit comments

Comments
 (0)