-
Notifications
You must be signed in to change notification settings - Fork 529
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
m\zod@4.2.1\node_modules\zod\v4\core\json-schema-processors.cjs:149
throw new Error("Date cannot be represented in JSON Schema");
^
Error: Date cannot be represented in JSON Schema
at Object.dateProcessor (C:\Users\user\Desktop\...\node_modules\.pnpm\zod@4.2.1\node_modules\zod\v4\core\json-schema-processors.cjs:149:15)
a- My zod schema
export const projectSchema = z.object({
id: z.number().int().positive(),
demo_url: z.url().nullable(),
oficial_url: z.url().nullable(),
repo_url: z.url().nullable(),
is_repository_private: z.boolean(),
start_date: z.coerce.date(),
end_date: z.coerce.date().nullable(),
portfolio_id: z.number().int().positive(),
}).strict();import { createZodDto } from "nestjs-zod";
import { z } from "zod";
import { projectSchema } from "../schemas/project.schema";
export const projectStoreDto = projectSchema
.omit({
id: true,
created_at: true,
updated_at: true,
})
.extend({
skill_ids: z.array(z.number()).optional(),
});
export type ProjectStoreDto = z.infer<typeof projectStoreDto>;
export class ProjectStoreDtoClass extends createZodDto(projectStoreDto) {}
// controller
@ApiOperation({ summary: "Create a new project" })
@ApiBody({ type: ProjectStoreDtoClass, description: "Project creation data" })
@ApiResponse({ status: 201, description: "Project created." })
@UseGuards(AuthenticatedGuard)
@UsePipes(new ZodPipe(projectStoreDto))
@Post("/")
store(@Body() body: ProjectStoreDto) {
return this.projectService.store(body);
}- When i comment this nest swagger main, no error in console
const config = new DocumentBuilder()
.setTitle("Astro-Test API")
.setDescription("API documentation for Astro-Test project")
.setVersion("1.0")
.addTag("users")
.build();
const document = SwaggerModule.createDocument(app, config);
app.use(
"/reference",
apiReference({
content: document,
}),
);Minimum reproduction code
c
Steps to reproduce
No response
Expected behavior
"@nestjs/common": "^11.1.10",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.10",
"@nestjs/swagger": "^11.2.3",
"@scalar/nestjs-api-reference": "^1.0.13",
"typescript": "^5.9.3",
zod": "^4.3.2"Package version
11.2.3
NestJS version
11.1.10
Node.js version
22.16.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Reactions are currently unavailable