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

Also generate zod schema's for parameters and body

Open sjroesink opened this issue 8 months ago • 3 comments

Description

At this point the Zod plugin only generates schema's for the responses. It would be useful if it would also generate schema's for the parameters and body.

sjroesink avatar Apr 18 '25 06:04 sjroesink

Yes would it be a very nice thing to add

Julien57970 avatar Apr 28 '25 08:04 Julien57970

Would be awesome to have this

anthony-lacrabere avatar Apr 28 '25 09:04 anthony-lacrabere

And thinking about it, the response is actually the least important to validate

sjroesink avatar May 15 '25 10:05 sjroesink

@sjroesink I get the request and going to make it happen, but curious how you're planning to use the parameter and body schemas?

mrlubos avatar May 29 '25 23:05 mrlubos

These will be available in the next release. Feedback would be appreciated! 🙌

mrlubos avatar May 30 '25 00:05 mrlubos

@mrlubos

@sjroesink I get the request and going to make it happen, but curious how you're planning to use the parameter and body schemas?

In my case, I will be creating forms for the request bodies and parameters. I want to pass a zod schema to these forms so I can parse / validate the eventual values on submit. I would also expect the SDKs to validate the bodies and parameters. Now only the response is validated. Ideally I want to choose which parts I want the SDK to validate because in my case I don't want to validate the responses (I can trust the response output is correct) - validating the response would therefor only negatively impact the performance (especially for large responses).

These will be available in the next release. Feedback would be appreciated! 🙌

Perfect, I'll have a look soon, thanks!

sjroesink avatar Jun 04 '25 14:06 sjroesink

I've updated request schemas in v0.74.0 a bit, it's now a single schema instead of separate schemas for each parameter and request body. Should be straightforward to add support for request validation with Zod from here 🏃

mrlubos avatar Jun 19 '25 15:06 mrlubos

Request validation added in v0.77.0 ✅

mrlubos avatar Jun 24 '25 19:06 mrlubos