bravado-core
bravado-core copied to clipboard
Return raw response
Adds a new config option "return_raw_response" that returns the raw decoded response (after json/msgpack decoding, skipping the call to unmarshal_schema_object).
Coverage increased (+0.003%) to 97.973% when pulling 12effce4149670b91db23c5d1444c36e81aff0f3 on gstarnberger:return_raw_response into 6f595cb4c41f541581624aae20f2f30f72453235 on Yelp:master.
I looked at request_options but I didn't find a way to implement the same functionality (without larger code changes). Essentially what I'd like to do is:
-
Add a new option that skips the call to unmarshal_schema_object for latency-sensitive use-cases.
-
Still be able to enable options such as validate_responses in dev/stage environments to verify that requests/responses match the spec.
All of this logic (response validation, response decoding, ...) is called in bravado_core.response.unmarshal_response so if I'd move the new code to a higher level I'd have to duplicate some of the unmarshal_response logic somewhere else (e.g., response validation, content-type detection, ...). For return_raw_response I followed the approach used for the use_models config option which is similar as it also determines how the response is returned.
How would an implementation that uses request options look like? Would I have to duplicate the deserialization logic (json, msgpack) and the response validation logic somewhere else?
@gstarnberger fair point ... During hackathon @sjaensch started to work a bit on async io bravado and we were discussing if it could make sense to move into bravado the logic for handling requests, so that could be already a sort of solution for you.
For your use case, I was thinking to add a request option (similar to also_return_response
) into bravado such that once it is enabled we're completely skipping the bravado-core interaction -> no validation, no unmarshaling and you still have access to the raw response (so bytes in case of msgpack).
Let me sync better with @sjaensch tomorrow morning, he could eventually have better ideas about your case 😄