bravado
bravado copied to clipboard
Headers validated case sensitive
When supplying headers using _request_options bravado's validation checks their names with case sensitivity, while it shouldn't, as HTTP header names are case insensitive.
That leads to SwaggerMappingError's when a header is required and the case sensitivity of its name differs between the OpenAPI specification and the provided header name in the code.
A workaround is to use a CaseInsensitiveDict instead of a dict for the headers in _request_config like:
from requests.structures import CaseInsensitiveDict
Pet = client.get_model('Pet')
Category = client.get_model('Category')
pet = Pet(id=42, name="tommy", category=Category(id=24))
swagger_client.pet.addPet(
body=pet,
_request_options={"headers": CaseInsensitiveDict(data={"foo": "bar"})},
).result()
While that workaround works fine I'd expect bravado to handle that internally in a transparent way for the user.