Skip to content
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

Use express-ajv-swagger-validation in middleware #81

Open
clemens-smartparking opened this issue Jul 12, 2019 · 1 comment
Open

Use express-ajv-swagger-validation in middleware #81

clemens-smartparking opened this issue Jul 12, 2019 · 1 comment

Comments

@clemens-smartparking
Copy link

clemens-smartparking commented Jul 12, 2019

I am using nestjs and I use the express-ajv-swagger-validation in the middleware (couldn't figure out how to do it otherwise in nestjs and I don't need routes).

I got a crash when calling swaggerValidator.validate(req, res, next) which I fixed by manually adding the route object to the request object:

req.route = {
   path: req.path
};

Do you think its possible to check for the route property and if it does not exist use req.path? This would make express-ajv-swagger-validation a bit more flexible to use.

@idanto
Copy link
Contributor

idanto commented Jul 16, 2019

I think this is a very simple API use case that we probably missed, you are welcome to create a PR with this fix :)

evelyne24 pushed a commit to evelyne24/express-ajv-swagger-validation that referenced this issue Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants