openapi-core/openapi_core/contrib/falcon/responses.py
2020-03-11 10:44:30 +00:00

20 lines
599 B
Python

"""OpenAPI core contrib falcon responses module"""
from openapi_core.validation.response.datatypes import OpenAPIResponse
class FalconOpenAPIResponseFactory(object):
@classmethod
def create(cls, response):
status_code = int(response.status[:3])
mimetype = ''
if response.content_type:
mimetype = response.content_type.partition(";")[0]
else:
mimetype = response.options.default_media_type
return OpenAPIResponse(
data=response.body,
status_code=status_code,
mimetype=mimetype,
)