bravado icon indicating copy to clipboard operation
bravado copied to clipboard

swagger client should not be modified by a service call.

Open podarsmarty opened this issue 9 years ago • 2 comments

For swaggerpy version 0.7.6 when we call and endpoint with a body parameter the header {'content-type': 'application/json'} is added for us. However, it is persisted which causes endpoints that don't need that header to fail.

i.e. - client.get_client(...).endpoints.endpoint(body={'some_data': 'some_data'})

workaround for now is

client.get_client(...).endpoints.endpoint(_request_options={'headers': {'content-type': 'application/json'}}, body={'some_data': 'some_data'})

podarsmarty avatar Jul 14 '15 23:07 podarsmarty

So this issue is that here we are fetching the _request_options reference and mutating it later. The dict provided by user should not get mutated at any cost. So, i think the fix should be:

_request_options = kwargs.pop('_request_options', {}).copy() or {}

which will needed to be patched to both swaggerpy and bravado.

prat0318 avatar Jul 15 '15 00:07 prat0318

Do I understand correctly this was fixed by #166?

lucafavatella avatar May 02 '17 09:05 lucafavatella