{"id":13454738,"url":"https://github.com/lzehrung/zod-express-openapi-routes","last_synced_at":"2026-01-17T05:04:48.890Z","repository":{"id":147029644,"uuid":"577179642","full_name":"lzehrung/zod-express-openapi-routes","owner":"lzehrung","description":"POC for cozy API validation, typing, and OpenAPI/swagger schema generation with Zod and Express","archived":false,"fork":false,"pushed_at":"2024-04-21T22:36:47.000Z","size":20067,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-28T21:41:25.911Z","etag":null,"topics":["api","api-routes","documentation-as-code","express","nodejs","openapi","openapi3","swagger","typescript","validation","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lzehrung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-12T06:37:15.000Z","updated_at":"2024-06-30T04:50:22.000Z","dependencies_parsed_at":"2024-04-21T23:41:36.594Z","dependency_job_id":"7d64c03e-5db8-4438-b92e-80faad99c377","html_url":"https://github.com/lzehrung/zod-express-openapi-routes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzehrung%2Fzod-express-openapi-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzehrung%2Fzod-express-openapi-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzehrung%2Fzod-express-openapi-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzehrung%2Fzod-express-openapi-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzehrung","download_url":"https://codeload.github.com/lzehrung/zod-express-openapi-routes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245222576,"owners_count":20580187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-routes","documentation-as-code","express","nodejs","openapi","openapi3","swagger","typescript","validation","zod"],"created_at":"2024-07-31T08:00:57.499Z","updated_at":"2026-01-17T05:04:48.839Z","avatar_url":"https://github.com/lzehrung.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"## Overview\n\n- Find an ergonomic way (minimize boilerplate and code duplication) to get typed, zod-validated express routes and an OpenAPI\n  schema at the same time\n- Minimize code duplication and boilerplate between express routes, request parameter validation, and OpenAPI definitions\n\n## Highlights\n\n- base `Controller` class that consolidates creation of express route, zod-validated request parameters, OpenAPI definition, and getting a typed `express.RouteHandler`: [src/zod-openapi-express-routes/zod-api.controller.ts](src/zod-openapi-express-routes/zod-api.controller.ts)\n- example controller instance: [src/products/products.controller.ts](src/products/products.controller.ts)\n- example request parameter zod schemas: [src/products/api-schemas.ts](src/products/api-schemas.ts)\n- example manually-defined file upload route using [multer](https://github.com/expressjs/multer) for uploads: [src/products/products.controller.ts#L148](src/products/products.controller.ts#L148)\n\n## Run the example\n\n- clone the repository\n- `npm install`\n- `npm run dev`\n- open the generated OpenAPI docs http://localhost:3250/api/reference\n- open the generated `swagger.json` http://localhost:3250/api/swagger.json\n- get a single resource http://localhost:3250/api/products/1\n- an invalid path parameter results in validation errors http://localhost:3250/api/products/abc\n\n## Dependencies\n\n- `@anatine/zod-openapi`: generates request parameter OpenAPI definitions from zod schemas\n- `openapi3-ts`: used to define OpenAPI schema in TypeScript\n- `swagger-ui-express`: serves the OpenAPI documentation\n- `zod`: used to define request parameter validation schemas\n\n## Limitations\n\n- file upload routes must be documented manually\n- haven't tested nested routers / routes\n- not extensively tested\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzehrung%2Fzod-express-openapi-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzehrung%2Fzod-express-openapi-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzehrung%2Fzod-express-openapi-routes/lists"}