openapi-zod-typed-express
v0.2.3
Published
Simple express runtime parser and documentation swagger generator with 100% support of Typescript static types
Maintainers
Readme
openapi-zodtyped-express
openapi-zodtyped-express keeps your endpoints documented using OPENAPI with just one single source of truth defined in the endpoints with zod schemas
- Generate OpenAPI API documentation
- Compile time validations - Infer Typescript static types out of the box
- Runtime validate each of your HTTP request with user-friendly error messages
All of this is done with a single higher-order-function used in the express endpoints.
So you can just simply wrap your handler with the apiDoc(...) and initialize project via initApiDocs()
Important info
- every transform in a zod schema has to be piped with z.pipe() into a output validator like this: pipe(z.number()) as zods toJSONSchema cant get the output type of a transform.
- at the moment it is not possible to chain more zod on the zDual type (everything has to be done in the two internal schemas of ZDual)
