Currently, the only option that can be customized is target, with the example from the README for instance:
const transform = createJsonSchemaTransform({
zodToJsonConfig: { target: "openapi-3.0" },
})
It would be great if we could customize the rest of zod's toJSONSchema options, and more notably for my use case, the override option.
The reason for that (for me) is that since zod v4, some schemas like UUIDs or ISO dates/date times have a huge pattern property that ends up absolutely everywhere in our OpenAPI schema. You could argue this might be an issue best addressed on the OpenAPI doc renderer (for my use case, Scalar) so that those patterns are only displayed optionally (like on hover over the type or something), but anyway, it's quite tedious having those huge patterns splattered everywhere, even in the OpenAPI schema itself. Here's an example of what it looks like:
Being that explicit, in my eyes, isn't needed in the OpenAPI schema, so I'd like to skip those. This is easily done when using zod's toJSONSchema function directly, for instance like that:
import * as z from 'zod';
const idSchema = z.object({ id: z.uuid() });
const jsonSchema = z.toJSONSchema(idSchema, {
override(ctx) {
if (ctx.jsonSchema.format === 'uuid') {
ctx.jsonSchema.pattern = undefined;
}
},
target: 'openapi-3.0',
});
It would be great to be able to pass this option in createJsonSchemaTransform({ zodToJsonConfig: { ... }}).
Currently, the only option that can be customized is
target, with the example from the README for instance:It would be great if we could customize the rest of zod's
toJSONSchemaoptions, and more notably for my use case, theoverrideoption.The reason for that (for me) is that since zod v4, some schemas like UUIDs or ISO dates/date times have a huge
patternproperty that ends up absolutely everywhere in our OpenAPI schema. You could argue this might be an issue best addressed on the OpenAPI doc renderer (for my use case, Scalar) so that those patterns are only displayed optionally (like on hover over the type or something), but anyway, it's quite tedious having those huge patterns splattered everywhere, even in the OpenAPI schema itself. Here's an example of what it looks like:Being that explicit, in my eyes, isn't needed in the OpenAPI schema, so I'd like to skip those. This is easily done when using zod's
toJSONSchemafunction directly, for instance like that:It would be great to be able to pass this option in
createJsonSchemaTransform({ zodToJsonConfig: { ... }}).