Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion openapi3/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def _request_handle_parameters(self, parameters={}):
self._request.url = self._request.url.format(**path_parameters)

def _request_handle_body(self, data):
if "application/json" in self.requestBody.content:
is_json = [k for k in self.requestBody.content.keys() if k.startswith('application/json')]
if is_json:
if isinstance(data, dict) or isinstance(data, list):
body = json.dumps(data)

Expand Down Expand Up @@ -362,6 +363,15 @@ def request(self, base_url, security={}, data=None, parameters={}, verify=True,
return

content_type = result.headers["Content-Type"]
expected_media = expected_response.content.get(content_type, None)

if expected_media is not None:
if content_type.lower().startswith("application/json"):
return expected_media.schema.model(result.json())
else:
raise NotImplementedError()

# Handle if received content type does not match expected content type excatly
if ';' in content_type:
# if the content type that came in included an encoding, we'll ignore
# it for now (requests has already parsed it for us) and only look at
Expand Down