Skip to content

Commit

Permalink
[DEV-3938] Backport spec-first#1191
Browse files Browse the repository at this point in the history
I am fixing the mime type hell in the current codebase.
  • Loading branch information
vmarkovtsev committed Apr 3, 2022
1 parent 412eb4b commit ca73c55
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions especifico/decorators/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def validate_response(self, data, status_code, headers, url):
response_definition = self.operation.response_definition(str(status_code), content_type)
response_schema = self.operation.response_schema(str(status_code), content_type)

if self.is_json_schema_compatible(response_schema):
if self.is_json_schema_compatible(response_schema, content_type):
v = ResponseBodyValidator(response_schema, validator=self.validator)
try:
data = self.operation.json_loads(data)
Expand All @@ -69,7 +69,7 @@ def validate_response(self, data, status_code, headers, url):
raise NonConformingResponseHeaders(message=msg)
return True

def is_json_schema_compatible(self, response_schema: dict) -> bool:
def is_json_schema_compatible(self, response_schema: dict, content_type: str) -> bool:
"""
Verify if the specified operation responses are JSON schema
compatible.
Expand All @@ -80,7 +80,7 @@ def is_json_schema_compatible(self, response_schema: dict) -> bool:
"""
if not response_schema:
return False
return all_json([self.mimetype]) or self.mimetype == "text/plain"
return all_json([content_type]) or content_type == "text/plain"

def __call__(self, function):
"""
Expand Down

0 comments on commit ca73c55

Please sign in to comment.