propagate validateApiSpec: false to ajv #543
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves issue 541
For context. We have a somewhat large spec file and would like to avoid the overhead of validating the spec on every request. There is also a concern that concurrent merges to our deploy could interject duplicate enum values, etc which would effectively kill the api. I created a test in our system specifically for validating the spec.
There is possibly a better way to do this and I am open to any suggestions that you might have.
For example, we could change the validateApiSpec key to an object|boolean (see OpenApiValidatorOpts.validateResponses) so that users of this package can decide how deeply they want to disable the validation.
Also, there is probably a cleaner way to pass the validateSchema flag to ajv than to override the options on each validator.
I didn't add any new tests yet but it is not breaking any existing tests and manually verified that ajv/lib/ajv.js:validateSchema does not get called with this override
-- edit --
I updated the branch so that it allows for passing in boolean or validation suppression options and added validateSchema to the baseOptions response