-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Hi,
I automatically generate my schema for my endpoints. My issue: The types are dates and the toJsonSchema for zod v4 doesnt allow Dates (https://zod.dev/json-schema#unrepresentable)
There is a workaround to convert Dates to string date-time (https://zod.dev/json-schema#override) But i don't know understand on how to use the loadVendor correctly.
Currently my loadVendor looks like this:
loadVendor('zod', { toOpenAPISchema: (schema, context) => convertToOpenAPISchema( toJSONSchema(schema, { io: 'input', override: (ctx) => { const def = ctx.zodSchema._zod.def; logger.info('def', { def }); if (def.type === 'date') { ctx.jsonSchema.type = 'string'; ctx.jsonSchema.format = 'date-time'; } }, }) as Omit<ReturnType<typeof toJSONSchema>, 'exclusiveMaximum'> & { exclusiveMaximum?: number; }, context ), });
I also need to make the type casting because the JsonSchemas dont align.
Current versions:
zod 4.1.12
hono 4.9.8
hono-openapi 1.1.0
What I need:
Instructions on how to use loadVendor correctly (Do I need to inject is somewhere?)
Ideal solution:
A option for hono-openapi to automatically convert specific types to something else.
Something like
openAPIRouteHandler(app, { overrides: { date: (d) => {} } }