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

Skip/bypass response validation #498

Open
zingmane opened this issue Jul 23, 2024 · 2 comments
Open

Skip/bypass response validation #498

zingmane opened this issue Jul 23, 2024 · 2 comments

Comments

@zingmane
Copy link

I try to configure the behaviour so that no responses are generally validated.
In my case, this is not necessary as the response is my own responsibility and a large number of tests ensure that all values are valid.

I would like to use exegesis only for validating requests, but still keep the nice integration of the swagger documentation.

I have noticed that the response validation can become very slow if I return large json arrays whose objects in turn contain a lot of property keys. (e.g. array length 100,000 with 100 prop keys each).
In my example, the request in the DB takes ~1 second, the validation approx. ~4 seconds.

I have tried to change the behaviour with the validateDefaultResponses option, but this does not work because I have explicitly documented the endpoint with http codes.

I can work around this by changing the documentation for all endpoints, which is not so practical.
Or I can set the content-type to json and return my response myself via JSON.stringify. However, this then has to be done individually for each endpoint.

In my opinion, the best and easiest way would be to define the behaviour globally via a new option, e.g. validateResponses defaults to true.

If it is false, the validateResponse function in OpenApi.js should simply not be called.

I could also modify it myself so that it works for me. But I think it would be nicer to have it in the core.
What do you think?

@jwalton
Copy link
Contributor

jwalton commented Jul 23, 2024

From reading the docs, I think the intent here was if you set onResponseValidationError to undefined, it would not bother to validate responses. And, in the code, we skip validation response if this is not set. But, we also don't allow you to not set it. -_-

I'd be happy to add a more explicit validateResponses option, too.

@zingmane
Copy link
Author

That would be great 👍

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

No branches or pull requests

2 participants