StefanTerdell / zod-to-json-schema

Converts Zod schemas to Json schemas
ISC License
886 stars 71 forks source link

Why doesn't get optional in path #100

Closed caoxing9 closed 10 months ago

caoxing9 commented 10 months ago

zodToJsonSchema( z .object({ tableId: z.number().optional(), recordId: z.string().uuid().optional(), }) .strict(), { target: 'openApi3', $refStrategy: 'none', } )

result:

  {
  type: 'object',
  properties: {
    tableId: { type: 'number' },
    recordId: { type: 'string', format: 'uuid' }
  },
  additionalProperties: false
}

why doesn't get required ?

caoxing9 commented 10 months ago

wow, i got it, only optional doesn's return required, my bad~