2019-11-21 22:50:57 +00:00
|
|
|
"""OpenAPI core contrib falcon responses module"""
|
|
|
|
from openapi_core.validation.response.datatypes import OpenAPIResponse
|
|
|
|
|
|
|
|
|
|
|
|
class FalconOpenAPIResponseFactory(object):
|
|
|
|
@classmethod
|
2020-02-17 16:33:01 +00:00
|
|
|
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
|
|
|
|
|
2019-11-21 22:50:57 +00:00
|
|
|
return OpenAPIResponse(
|
2020-02-17 16:33:01 +00:00
|
|
|
data=response.body,
|
|
|
|
status_code=status_code,
|
|
|
|
mimetype=mimetype,
|
2019-11-21 22:50:57 +00:00
|
|
|
)
|