Open zingmane opened 1 month ago
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.
That would be great 👍
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 viaJSON.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
, thevalidateResponse
function inOpenApi.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?