openapi-ts
openapi-ts copied to clipboard
Add options for datetime into zod plugin
Actually, we only have something like this
export const zOrder = z.object({
complete: z.boolean().optional(),
id: z.coerce.bigint().optional(),
petId: z.coerce.bigint().optional(),
quantity: z.number().int().optional(),
shipDate: z
.string()
.datetime()
.optional(),
status: z.enum(['placed', 'approved', 'delivered']).optional(),
});
Tha goal is providing datetime options given by zod documentation https://zod.dev/?id=datetimes
With this kind of plugin declaration inside openapi-ts.config.ts
{
dateTimeOptions: {
local: true,
offset: true,
precision: 3,
},
name: 'zod',
},
we can have something like this
export const zOrder = z.object({
complete: z.boolean().optional(),
id: z.coerce.bigint().optional(),
petId: z.coerce.bigint().optional(),
quantity: z.number().int().optional(),
shipDate: z
.string()
.datetime({ local: true, offset: true, precision: 3 })
.optional(),
status: z.enum(['placed', 'approved', 'delivered']).optional(),
});
I'm not confortables about hey-api plugins so, feel free to make corrections.