Skip to content

Commit 6a75b2e

Browse files
committed
feat(runtime): add support for any, unknown, union and intersect in typebox route
1 parent 4886906 commit 6a75b2e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

example/src/pages/api/typeboxRoute/[test].ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ export const TypeboxRouteSchema = typeboxRouteSchema({
55
body: Type.Object({ error: Type.Boolean() }),
66
query: Type.Object({ test: Type.String() }),
77
responses: {
8-
200: Type.Object({ hello: Type.String() }),
8+
200: Type.Intersect([Type.Object({ hello: Type.String() })], Type.Object({})),
99
404: Type.Object({ error: Type.String() }),
10+
405: Type.Any(),
1011
500: Type.Null(),
1112
},
1213
});

packages/runtime/src/route/typeboxRoute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Kind, Static, TNull, TObject } from "@sinclair/typebox";
1+
import { Kind, Static, TAny, TIntersect, TNull, TObject, TUnion, TUnknown } from "@sinclair/typebox";
22
import fastJson from "fast-json-stringify";
33
import { NextApiRequest, NextApiResponse } from "next";
44

55
import { ajvOptions, createAjv } from "./ajv";
66
import { OrPromise, returnError, Serializer, ValueOf } from "./utils";
77

8-
export type TypeboxReturnType = TObject | TNull;
8+
export type TypeboxReturnType = TObject | TNull | TIntersect | TUnion | TAny | TUnknown;
99

1010
export interface TypeboxRouteSchema<
1111
TQuery extends TObject = TObject,

0 commit comments

Comments
 (0)