-
-
Notifications
You must be signed in to change notification settings - Fork 216
Open
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
5.4.0
Plugin version
9.5.1
Node.js version
22
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Operating System: Arch Linux Kernel: Linux 6.15.6-arch1-1
Description
Hi, I'm using @fastify/type-provider-typebox to generate schemas, I noticed that when I pass type null, swagger doesn't understand this type
Generic type
import { type TSchema, Type } from "@sinclair/typebox";
export const SuccessResponseSchema = <T extends TSchema>(T: T) =>
Type.Object({
status: Type.Literal("success"),
data: T,
});Usage in the function
import {
type FastifyPluginAsyncTypebox,
Type,
} from "@fastify/type-provider-typebox";
import { SignInSchema } from "../schemas/auth/sign-in.schema.js";
import {
ErrorResponseSchema,
SuccessResponseSchema,
ValidationErrorResponseSchema,
} from "../schemas/base.js";
const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
fastify.post(
"/auth/sign-up",
{
schema: {
body: SignInSchema,
response: {
201: SuccessResponseSchema(Type.Null()),
400: Type.Union([ErrorResponseSchema, ValidationErrorResponseSchema]),
},
tags: ["Authentication"],
},
},The result
Link to code that reproduces the bug
Included in the description
Expected Behavior
The Type.Null() schema from TypeBox must be properly supported in the generated OpenAPI (Swagger) specification.
Metadata
Metadata
Assignees
Labels
No labels