openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Zod Coerce all/certain types

Open juggy opened this issue 4 months ago • 2 comments

Description

Allow the generated code to coerce certain types (number for example). Right now the generation is pretty static and do not allow small configuration change.

Also can the zod generated schemas be added to the generated index.ts for easier imports?

juggy avatar Sep 30 '25 14:09 juggy

@juggy

Allow the generated code to coerce certain types (number for example).

Do you have an example of what you're trying to generate?

Also can the zod generated schemas be added to the generated index.ts for easier imports?

Yes.

mrlubos avatar Nov 12 '25 23:11 mrlubos

Some common example are:

  • non empty string string().min(1)
  • non iso date iso.date() -> date()
  • change all the numbers to coerce strings

I can refine on a usage basis, but that would be nice to allow to change the generation with some defaults.

juggy avatar Nov 13 '25 14:11 juggy