cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

[Feature Request] Add integration with validation libraries (eg `zod`) #270

Closed Lonli-Lokli closed 11 months ago

Lonli-Lokli commented 1 year ago

It's mostly a discussion, not a feature request, as I still don't know is it possible with template generating.

There are multiple libraries for validating responses from API; I prefer to use zod. And I would like to have an angular HTTP client with data validation automatically, while now I have to do this 1) Generate default client from openapi schema with ng-openapi-gen 2) Generate zod schema from openapi with https://github.com/josejulio/openapi2typescript/tree/main/packages/cli 3) Create wrappers for each service to put zod schemas

Basically, I would like to have smth similar to https://github.com/ecyrbe/zodios-openapi but with Angular

dsinghvi commented 1 year ago

@Lonli-Lokli I work on an open source project called Fern and our generated TypeScript client comes with request/response validation built in. Our clients have a serde layer where we validate the JSON and process the input in certain cases (e.g. turning string into Date, turning an array into a Set). Would that be useful?

luisfpg commented 11 months ago

Sorry for late reply. I consider ng-openapi-gen feature-complete, and I have very short time for it nowadays. So the idea is to only include bug fixes...