openapi-core/openapi_core/schema/content/models.py

22 lines
511 B
Python
Raw Normal View History

2018-05-30 13:46:54 +00:00
"""OpenAPI core content models module"""
import fnmatch
from six import iteritems
from openapi_core.schema.content.exceptions import MimeTypeNotFound
class Content(dict):
def __getitem__(self, mimetype):
try:
return super(Content, self).__getitem__(mimetype)
except KeyError:
pass
for key, value in iteritems(self):
if fnmatch.fnmatch(mimetype, key):
return value
2019-06-18 11:39:07 +00:00
raise MimeTypeNotFound(mimetype, list(self.keys()))