openapi-core icon indicating copy to clipboard operation
openapi-core copied to clipboard

Error out in human friendly way if mimetype is missing on response

Open domenkozar opened this issue 7 years ago • 2 comments

Currently one gets:

../../../../.local/share/virtualenvs/woocart-api-zie1bQwL/lib/python3.6/site-packages/openapi_core/validation/response/validators.py:37: in validate
    data, data_errors = self._get_data(response, operation_response)
../../../../.local/share/virtualenvs/woocart-api-zie1bQwL/lib/python3.6/site-packages/openapi_core/validation/response/validators.py:53: in _get_data
    media_type = operation_response[response.mimetype]
../../../../.local/share/virtualenvs/woocart-api-zie1bQwL/lib/python3.6/site-packages/openapi_core/schema/responses/models.py:21: in __getitem__
    return self.content[mimetype]
../../../../.local/share/virtualenvs/woocart-api-zie1bQwL/lib/python3.6/site-packages/openapi_core/schema/content/models.py:18: in __getitem__
    if fnmatch.fnmatch(mimetype, key):  
../../../../.local/share/virtualenvs/woocart-api-zie1bQwL/lib/python3.6/fnmatch.py:34: in fnmatch
    name = os.path.normcase(name)                                  
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                                          
s = None                             
       
    def normcase(s):                                                                                                                                     
        """Normalize case of pathname.  Has no effect under Posix"""
>       s = os.fspath(s)
E       TypeError: expected str, bytes or os.PathLike object, not NoneType

domenkozar avatar Jul 13 '18 16:07 domenkozar

MimeTypeNotFound exception exists, but it's not raised.

domenkozar avatar Sep 05 '18 14:09 domenkozar

I ran into this using requests and RequestsOpenAPIRequest, when the server sends Content-type instead of Content-Type. :roll_eyes:

remram44 avatar Jan 12 '21 20:01 remram44