{"id":13625831,"url":"https://github.com/cdimascio/express-openapi-validator","last_synced_at":"2025-05-12T15:22:00.014Z","repository":{"id":39620459,"uuid":"176581314","full_name":"cdimascio/express-openapi-validator","owner":"cdimascio","description":"🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.1.x or 3.0.x specification","archived":false,"fork":false,"pushed_at":"2025-05-11T19:47:54.000Z","size":10933,"stargazers_count":948,"open_issues_count":182,"forks_count":219,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-11T20:27:43.635Z","etag":null,"topics":["connect-middleware","express","express-middleware","expressjs","hacktoberfest","middleware","nodejs","openapi","openapi-validator","openapi3","request-validation","rest-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdimascio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE_HISTORY.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://www.buymeacoffee.com/m97tA5c"]}},"created_at":"2019-03-19T19:08:05.000Z","updated_at":"2025-05-11T19:47:48.000Z","dependencies_parsed_at":"2024-04-28T22:25:59.537Z","dependency_job_id":"bdee06f8-ede7-4bfd-bf77-72c7ab268854","html_url":"https://github.com/cdimascio/express-openapi-validator","commit_stats":{"total_commits":1664,"total_committers":115,"mean_commits":"14.469565217391304","dds":0.7259615384615384,"last_synced_commit":"946aab8c3d62a4b5c4945224163db9d3861c8a44"},"previous_names":[],"tags_count":196,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fexpress-openapi-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fexpress-openapi-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fexpress-openapi-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fexpress-openapi-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdimascio","download_url":"https://codeload.github.com/cdimascio/express-openapi-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253632847,"owners_count":21939377,"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":["connect-middleware","express","express-middleware","expressjs","hacktoberfest","middleware","nodejs","openapi","openapi-validator","openapi3","request-validation","rest-api"],"created_at":"2024-08-01T21:02:03.221Z","updated_at":"2025-05-12T15:22:00.001Z","avatar_url":"https://github.com/cdimascio.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/m97tA5c"],"categories":["TypeScript","rest-api"],"sub_categories":[],"readme":"# 🦋 express-openapi-validator\n\n[![build workflow](https://github.com/cdimascio/express-openapi-validator/actions/workflows/default.yml/badge.svg)](#) [![](https://img.shields.io/npm/v/express-openapi-validator.svg)](https://www.npmjs.com/package/express-openapi-validator) [![](https://img.shields.io/npm/dm/express-openapi-validator?color=blue)](https://www.npmjs.com/package/express-openapi-validator) [![All Contributors](https://img.shields.io/github/contributors/cdimascio/express-openapi-validator\n)](#contributors) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-openapi-validator/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-openapi-validator?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1570a06f609345ddb237114bbd6ceed7)](https://www.codacy.com/manual/cdimascio/express-openapi-validator?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=cdimascio/express-openapi-validator\u0026utm_campaign=Badge_Grade) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator)  [![](https://img.shields.io/badge/documentation-yes-informational)](https://cdimascio.github.io/express-openapi-validator-documentation/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](#license)\n\n**An OpenApi validator for ExpressJS** that automatically validates **API** _**requests**_ and _**responses**_ using an **OpenAPI 3** specification.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/cdimascio/express-openapi-validator/master/assets/express-openapi-validator-logo-v2.png\" width=\"600\"\u003e\n\u003c/p\u003e\n\n[🦋express-openapi-validator](https://github.com/cdimascio/express-openapi-validator) is an unopinionated library that integrates with new and existing API applications. express-openapi-validator lets you write code the way you want; it does not impose any coding convention or project layout. Simply, install the validator onto your express app, point it to your **OpenAPI 3.0.x** or **3.1.x** specification, then define and implement routes the way you prefer. See an [example](https://cdimascio.github.io/express-openapi-validator-documentation/guide-standard/).\n\n**Features:**\n\n- ✔️ request validation\n- ✔️ response validation (json only)\n- 👮 security validation / custom security functions\n- 👽 3rd party / custom formats / custom data serialization-deserialization\n- 🧵 optionally auto-map OpenAPI endpoints to Express handler functions\n- ✂️ **\\$ref** support; split specs over multiple files\n- 🎈 file upload\n- ✏️ OpenAPI 3.0.x and 3.1.x spec support\n- ✨ Express 4 and 5 support\n\n\n\n**Docs:**\n- 📖 [documentation](https://cdimascio.github.io/express-openapi-validator-documentation/)\n\n[![GitHub stars](https://img.shields.io/github/stars/cdimascio/express-openapi-validator.svg?style=social\u0026label=Star\u0026maxAge=2592000)](https://GitHub.com/cdimascio/express-openapi-validator/stargazers/) [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/cdimascio/express-openapi-validator.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20express-openapi-validator%20by%20%40CarmineDiMascio%20https%3A%2F%2Fgithub.com%2Fcdimascio%2Fexpress-openapi-validator%20%F0%9F%91%8D)\n\n[OAS 3.1](https://github.com/cdimascio/express-openapi-validator/pull/882) support available in `\u003e=v5.4.0`!\n\n[Express 5](https://expressjs.com/en/5x/api.html) support available in `\u003e=v5.5.0`!_\n\n\n[NestJS](https://github.com/cdimascio/express-openapi-validator/tree/master/examples/9-nestjs)\n[Koa](https://github.com/cdimascio/express-openapi-validator/tree/lerna-fastify/packages/koa-openapi-validator) and [Fastify](https://github.com/cdimascio/express-openapi-validator/tree/lerna-fastify/packages/fastify-openapi-validator) now available! 🚀\n\n\n## Install\n\n```shell\nnpm install express-openapi-validator\n```\n\n## Usage\n\n1. Require/import the openapi validator\n\n```javascript\nconst OpenApiValidator = require('express-openapi-validator');\n```\n\nor\n\n```javascript\nimport * as OpenApiValidator from 'express-openapi-validator';\n```\n\n2. Install the middleware\n\n```javascript\napp.use(\n  OpenApiValidator.middleware({\n    apiSpec: './openapi.yaml',\n    validateRequests: true, // (default)\n    validateResponses: true, // false by default\n  }),\n);\n```\n\n3. Register an error handler\n\n```javascript\napp.use((err, req, res, next) =\u003e {\n  // format error\n  res.status(err.status || 500).json({\n    message: err.message,\n    errors: err.errors,\n  });\n});\n```\n\n_**Important:** Ensure express is configured with all relevant body parsers. Body parser middleware functions must be specified prior to any validated routes. See an [example](#example-express-api-server)_.\n\n## [Documentation](https://cdimascio.github.io/express-openapi-validator-documentation/)\n\nSee the [doc](https://cdimascio.github.io/express-openapi-validator-documentation/) for complete documenation\n\n_deprecated_ [legacy doc](https://github.com/cdimascio/express-openapi-validator/wiki) \n\n## License\n\n[MIT](LICENSE)\n\n\u003ca href=\"https://www.buymeacoffee.com/m97tA5c\" target=\"_blank\"\u003e\u003cimg src=\"https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Fexpress-openapi-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdimascio%2Fexpress-openapi-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Fexpress-openapi-validator/lists"}