You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Things have been working great for 200 responses from my API, but I am interested in using flex to validate API responses for invalid inputs like when a query parameter is not within an enum. The issue I have right now is that the validator rejects the request as being malformed (which it is by design) before it verifies the response. I'd like to file a PR to allow me to just validate the response, but it seems like there are a few options I can explore:
Call validate_response directly, but this seems like I am violating the abstraction, and I would also need to normalize the response before I pass it in. But this would work now without any changes, I think
Refactor the validate_api_call method to call a validate_api_response method that is a wrapper around the normalize_response and validate_response methods that I could just call from methods where I want to validate the response.
Add a parameter like only= to validate_api_call that takes either response or request as arguments and uses that for calling the validation.
I was leaning towards the third option at first, but I realized that people might think they don't have to pass in a request object when only=response but we still need that request object to know the HTTP method we are validating the response for. So I am kinda leaning towards the second option since it makes that more explicit. What do you think?
The text was updated successfully, but these errors were encountered:
I vote for option 2. Let me elaborate a little more.
Option 2 will allow us to keep it backward compatible, and add a new functionality. Adding a new parameter can cause confusion when one changes a version from another.
Things have been working great for 200 responses from my API, but I am interested in using flex to validate API responses for invalid inputs like when a query parameter is not within an enum. The issue I have right now is that the validator rejects the request as being malformed (which it is by design) before it verifies the response. I'd like to file a PR to allow me to just validate the response, but it seems like there are a few options I can explore:
validate_response
directly, but this seems like I am violating the abstraction, and I would also need to normalize the response before I pass it in. But this would work now without any changes, I thinkvalidate_api_call
method to call avalidate_api_response
method that is a wrapper around thenormalize_response
andvalidate_response
methods that I could just call from methods where I want to validate the response.only=
tovalidate_api_call
that takes eitherresponse
orrequest
as arguments and uses that for calling the validation.I was leaning towards the third option at first, but I realized that people might think they don't have to pass in a request object when
only=response
but we still need that request object to know the HTTP method we are validating the response for. So I am kinda leaning towards the second option since it makes that more explicit. What do you think?The text was updated successfully, but these errors were encountered: