diff --git a/packages/zod/src/index.ts b/packages/zod/src/index.ts index ffb112053..94bfaa0e8 100644 --- a/packages/zod/src/index.ts +++ b/packages/zod/src/index.ts @@ -42,8 +42,6 @@ const resolveZodType = (schemaTypeValue: SchemaObject['type']) => { switch (schemaTypeValue) { case 'integer': return 'number'; - case 'null': - return 'mixed'; default: return schemaTypeValue ?? 'any'; } diff --git a/packages/zod/src/zod.test.ts b/packages/zod/src/zod.test.ts index 4271108c9..cf29f6ff9 100644 --- a/packages/zod/src/zod.test.ts +++ b/packages/zod/src/zod.test.ts @@ -10,6 +10,7 @@ const queryParams: ZodValidationSchemaDefinitionInput = { functions: [ ['number', undefined], ['optional', undefined], + ['null', undefined], ], consts: [], }, @@ -36,7 +37,7 @@ describe('parseZodValidationSchemaDefinition', () => { const parseResult = parseZodValidationSchemaDefinition(queryParams); expect(parseResult.zod).toBe( - 'zod.object({\n "limit": zod.number().optional(),\n "q": zod.array(zod.string()).optional()\n})', + 'zod.object({\n "limit": zod.number().optional().null(),\n "q": zod.array(zod.string()).optional()\n})', ); }); }); @@ -46,7 +47,7 @@ describe('parseZodValidationSchemaDefinition', () => { const parseResult = parseZodValidationSchemaDefinition(queryParams, true); expect(parseResult.zod).toBe( - 'zod.object({\n "limit": zod.coerce.number().optional(),\n "q": zod.array(zod.coerce.string()).optional()\n})', + 'zod.object({\n "limit": zod.coerce.number().optional().null(),\n "q": zod.array(zod.coerce.string()).optional()\n})', ); }); });