-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrating with input validation #21
Comments
Have you tried something like express openapi validator? |
You should be able to do something like this: const openapi = require('openapi-comment-parser');
const validator = require('express-openapi-validator');
const spec = openapi();
app.use(validator.middleware({ apiSpec: spec })); |
Thanks, will try that and see how it works 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this is out of the scope of this library, but I am asking here to see if someone have already given a thought about this and solved it somehow within the openapi ecosystem.
A lot of boilerplate in any api service has to do with validating user's input. There are all kind of json schema validators and if you're using Typescript, you can use something like class-validator to decorate your classes and validate the user's input according to the requirements.
Ideally, we should write the openapi definitions one time in our code base with openapi-comment-parser syntax and then somehow use it to validate the requests according to the spec. I guess this will require "compiling" the comments into a openapi spec file and then using one of the validators to verify the user's input.
Has anyone tried anything like this before and can suggest an approach that worked for them ?
Thank you for this library
The text was updated successfully, but these errors were encountered: