Im looking to find a tool/framework which will allow me to validate/check the model of a received request(s) with a schema thats defined in the swagger documentation.
Asked
Active
Viewed 135 times
-1
-
Are you seeking recommendations for tools/software libraries for validating requests? – Jeffrey Ram Sep 03 '22 at 20:42
-
Yes!Thats what im looking for if you have any good suggestions – Alex Mathew Sep 03 '22 at 21:19
1 Answers
0
There are multiple open source packages for NPM that can validate requests and responses based on a swagger file. Here's one example:
https://www.npmjs.com/package/express-openapi-validator
import * as OpenApiValidator from 'express-openapi-validator';
app.use(
OpenApiValidator.middleware({
apiSpec: './openapi.yaml',
validateRequests: true, // (default)
validateResponses: true, // false by default
}),
);

Stefan Pfaffel
- 119
- 3
-
Thanks for the response Stefan!Do you happen to know any tool in which we can specify a swagger definition path and it validates the request against that specific defintion.Example: Something identical to the feature in swagger-tools (swagger-tools.spec.v2.validateModel) – Alex Mathew Sep 06 '22 at 20:58