anymaniax / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
2.36k stars 270 forks source link

feat(zod): add option coerce #1310

Closed anymaniax closed 1 month ago

anymaniax commented 1 month ago

Status

READY

Description

Add option coerce to zod client

soartec-lab commented 1 month ago

@anymaniax @melloware

Although it is an undocumented specification, it is actually possible to configure it so that coerce is used even when the coerceTypes option is specified.

https://github.com/anymaniax/orval/blob/master/packages/zod/src/index.ts#L327-L329

However, you cannot specify parameters and it will apply to all objects. I think the options supported this time are good because they can be set in more detail. From an overall perspective, there are multiple options with the same settings, so I would like to unify them. My suggestion is to deprecate coerceTypes and remove it in the next two versions, what do you think?

anymaniax commented 1 month ago

@soartec-lab I already added the deprecated warning on coerceTypes. if you use it or in the documentation directly

soartec-lab commented 1 month ago

@anymaniax Oops, you already deprecated it on this PR. I'm careful to remove it in the next two versions or later.