diff --git a/packages/nestjs-zod/src/openapi/zod-to-openapi.test.ts b/packages/nestjs-zod/src/openapi/zod-to-openapi.test.ts index ae0c916..1a056af 100644 --- a/packages/nestjs-zod/src/openapi/zod-to-openapi.test.ts +++ b/packages/nestjs-zod/src/openapi/zod-to-openapi.test.ts @@ -94,7 +94,16 @@ describe.each([ expect(openApiObject).toMatchSnapshot() }) - + + it('should serialize dates', () => { + const schema = z.date() + const openApiObject = zodToOpenAPI(schema) + + expect(openApiObject).toEqual({ + type: 'string', + }) + }); + it('should serialize objects', () => { const schema = z.object({ prop1: z.string(), diff --git a/packages/nestjs-zod/src/openapi/zod-to-openapi.ts b/packages/nestjs-zod/src/openapi/zod-to-openapi.ts index 66e8d66..1ad056f 100644 --- a/packages/nestjs-zod/src/openapi/zod-to-openapi.ts +++ b/packages/nestjs-zod/src/openapi/zod-to-openapi.ts @@ -51,6 +51,10 @@ export function zodToOpenAPI( } } + if (is(zodType, z.ZodDate)) { + object.type = 'string' + } + if (is(zodType, z.ZodPassword)) { const { checks } = zodType._def const regex = zodType.buildFullRegExp()