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

Option to accept unhandled routes #224

Closed
Cactusbone opened this issue Jan 29, 2020 · 4 comments
Closed

Option to accept unhandled routes #224

Cactusbone opened this issue Jan 29, 2020 · 4 comments
Labels
question Further information is requested

Comments

@Cactusbone
Copy link

For routes not defined in specs, I'd like to be able to not have a failure, for examples when routes are added after OpenApiValidator.install call (in my case asynchronously), or to be able to have multiple specs with overlapping baseUrl (in multiple OpenApiValidator instances), to sort code to my liking.

It this already possible ?

@Cactusbone Cactusbone changed the title Option to accepte unhandled routes Option to accept unhandled routes Jan 29, 2020
@cdimascio
Copy link
Owner

cdimascio commented Jan 29, 2020

@Cactusbone thanks for the question.
there are few options.

  1. you can instruct the validator to ignore certain routes via a regex. have a look at the ignorePaths option. any routes matched by the regex will be ignored by the validator
  2. you can also have multiple openAPI specs using distinct validator instances. Overlapping routes should work. take a look at the multiple validators/specs example to get started
  3. (likely not exactly what you're looking for, but) any routes not defined under basePath are ignored by the validator.

let me know if this helps or if you run into any issues. we certainly, want me to ensure this scenario works for you. feel free to reach on our gitter channel as well

@cdimascio cdimascio added the question Further information is requested label Jan 31, 2020
@Cactusbone
Copy link
Author

@cdimascio thanks for the answer

I'm trying to add openapi-validator gradually in an already existing project, so we have a lot of existing routes, and we'd like to only use openapi-validator for specific routes, without breaking our usual REST route organization, mutiple validators example use a distinct baseUrl for each validator instance. I'll try overlapping routes when I'll need them though :)

Right now i'll use basePath, and try to call install after every other route is configured

@cdimascio
Copy link
Owner

@Cactusbone That should work. ignorePaths is also your friend. With ignorePaths you should construct the regex to match all routes you plan to ignore.

closing this issue for now. If you find the existing functionality doesn't suit your needs, please re-open and we'll look to provide a better solution.

thanks for your interest in the project

@Cactusbone
Copy link
Author

ignorePaths is kinda hard to maintain though, watchPath regexp or a flag to allow unknown routes would be easier to use in my case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants