StefanTerdell / zod-to-json-schema

Converts Zod schemas to Json schemas
ISC License
854 stars 67 forks source link

All fields are getting added to required #107

Closed Dhruv-Garg79 closed 6 months ago

Dhruv-Garg79 commented 6 months ago
        zodToJsonSchema(z.object({ message: z.string(), data: schema.response.deepPartial() }), {
            $refStrategy: 'none',
        }) as any,

I am using the above code for creating JSON schema for zod schema where all fields are optional. But this code is not working anymore. I tried earlier versions of zod-to-josn-schema, but it's still not working

Dhruv-Garg79 commented 6 months ago

I found the issue, it seems to be with the zod itself. when we use .and in zod schema it makes fields as required, but when we use .augment it works as expected