Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

z.string().datetime() is not generated correctly the format is missed in the openapi spec #80

Closed
mbsanchez01 opened this issue Dec 1, 2023 · 2 comments

Comments

@mbsanchez01
Copy link

When I use createZodDto with a schema like:

const CreateFanDto = z
  .object({
    gender: z.enum(['male', 'female', 'other']).nullish(),
    status: z.enum(['active', 'inactive']).optional(),
    firstname: z.string().nullish(),
    lastname: z.string().nullish(),
    phone: z.string().nullish(),
    address: z.string().nullish(),
    birthDate: z.string().datetime().nullish(),
    email: z.string().email(),
  })

It generates birthDate as string without format, but like indicated in the README for v3.0.0 it should accept native datetime and should generate the field as string with $datetime format.

@GustavoOS
Copy link

I think this is related to #13

@mbsanchez01
Copy link
Author

mbsanchez01 commented Apr 11, 2024

I think it is not the same issue, he is asking for the example property, I'm talking about the format property. With the previous schema the birthdate is generated like:

"birthDate": {
     "type": "string"
}

and it should be generated like


"birthDate": {
  "type": "string",
  "format": "date-time"
},

@risen228 risen228 closed this as completed May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants