Again, we want to enforce that your server adheres to the specification. Luckily, we have some fancy middleware that will make sure our requests and responses match the specification. Let’s use openapi-express-validator
.
We can then use it as middleware to make sure that our responses are up-to-snuff.
app.use(
OpenApiValidator.middleware({
apiSpec: './openapi.json',
validateRequests: true,
validateResponses: true,
}),
);