🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.1.x or 3.0.x specification
TypeScript
1,005
1,383 commits
updated Sep 30, 2026
An OpenApi validator for ExpressJS that automatically validates API requests and responses using an OpenAPI 3 specification.
🦋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.
Features:
Docs:
Express 5 support available in >=v5.5.0!
OAS 3.1 support available in >=v5.4.0!
NestJS Koa and Fastify now available! 🚀
npm install express-openapi-validator
const OpenApiValidator = require('express-openapi-validator');
or
import * as OpenApiValidator from 'express-openapi-validator';
app.use(
OpenApiValidator.middleware({
apiSpec: './openapi.yaml',
validateRequests: true, // (default)
validateResponses: true, // false by default
}),
);
app.use((err, req, res, next) => {
// format error
res.status(err.status || 500).json({
message: err.message,
errors: err.errors,
});
});
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.
See the doc for complete documenation
deprecated legacy doc
Overall
Maintained
Code review
Latest release
Releases this year
151 followers · starred Sep 2024
14 followers · starred Apr 2022
51 followers · starred Jan 2024
138 followers · starred Jul 2026
🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.1.x or 3.0.x specification
TypeScript
1,005
1,383 commits
updated Sep 30, 2026
An OpenApi validator for ExpressJS that automatically validates API requests and responses using an OpenAPI 3 specification.
🦋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.
Features:
Docs:
Express 5 support available in >=v5.5.0!
OAS 3.1 support available in >=v5.4.0!
NestJS Koa and Fastify now available! 🚀
npm install express-openapi-validator
const OpenApiValidator = require('express-openapi-validator');
or
import * as OpenApiValidator from 'express-openapi-validator';
app.use(
OpenApiValidator.middleware({
apiSpec: './openapi.yaml',
validateRequests: true, // (default)
validateResponses: true, // false by default
}),
);
app.use((err, req, res, next) => {
// format error
res.status(err.status || 500).json({
message: err.message,
errors: err.errors,
});
});
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.
See the doc for complete documenation
deprecated legacy doc
Overall
Maintained
Code review
Latest release
Releases this year
151 followers · starred Sep 2024
14 followers · starred Apr 2022
51 followers · starred Jan 2024
138 followers · starred Jul 2026