ecyrbe / zodios

typescript http client and server with zod validation
https://www.zodios.org/
MIT License
1.71k stars 46 forks source link

Validating request but not response ? #185

Closed astahmer closed 2 years ago

astahmer commented 2 years ago

Currently we can validate both the request payload sent and the response content using validate or none

Continuing my reasoning (and use-cases for openapi-zod-client) that not all APIs are in our own control, and therefore that we can only control what we send in the request payload,

would you consider having a validate mode (as a string enum ?) with the current boolean ?

something like: validate: "request" | "response" | boolean

tbh I don't know if a response mode would really be useful but I added it in the example above so that every options are available

ecyrbe commented 2 years ago

Hello Alex,

Thank you for the suggestion. Yes, this could be an option passed to the validation plugin. I think validating both request and response is better for everyone, even on controlled APIs. It allows for fail fast strategies. But yes, i should not impose my views on zodios users. I'll add this.

astahmer commented 2 years ago

100% agree that everything should be validated on controlled API, i'm still in those use-cases where I don't have any control on the API used 😓

thanks for the quick answer !

ecyrbe commented 2 years ago

this is now available on @zodios/core v10.1.0

astahmer commented 2 years ago

that was quick 😄 ! thanks