Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ARCHITECTURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ This document describes the high-level architecture of Connexion.
Apps
----

A Connexion ``App`` or application wraps a specific framework application (currently Flask or
AioHttp) and exposes a standardized interface for users to create and configure their Connexion
A Connexion ``App`` or application wraps a specific framework application (currently Flask) and exposes a standardized interface for users to create and configure their Connexion
application.

While a Connexion app implements the WSGI interface, it only acts ass a pass-through and doesn't
Expand Down
8 changes: 0 additions & 8 deletions connexion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,5 @@
App = FlaskApp
Api = FlaskApi

try:
from .apis.aiohttp_api import AioHttpApi
from .apps.aiohttp_app import AioHttpApp
except ImportError as e: # pragma: no cover
_aiohttp_not_installed_error = not_installed_error(e)
AioHttpApi = _aiohttp_not_installed_error
AioHttpApp = _aiohttp_not_installed_error

# This version is replaced during release process.
__version__ = '2020.0.dev1'
38 changes: 3 additions & 35 deletions connexion/apis/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pathlib
import sys
import typing as t
import warnings
from enum import Enum

from ..decorators.produces import NoContent
Expand All @@ -19,7 +18,6 @@
from ..options import ConnexionOptions
from ..resolver import Resolver
from ..spec import Specification
from ..utils import is_json_mimetype

MODULE_PATH = pathlib.Path(__file__).absolute().parent.parent
SWAGGER_UI_URL = 'ui'
Expand Down Expand Up @@ -256,7 +254,6 @@ def get_response(self, response, mimetype=None, request=None):
"""
This method converts a handler response to a framework response.
This method should just retrieve response from handler then call `cls._get_response`.
It is mainly here to handle AioHttp async handler.
:param response: A response to cast (tuple, framework response, etc).
:param mimetype: The response mimetype.
:type mimetype: Union[None, str]
Expand Down Expand Up @@ -348,18 +345,7 @@ def _response_from_handler(
def get_connexion_response(cls, response, mimetype=None):
""" Cast framework dependent response to ConnexionResponse used for schema validation """
if isinstance(response, ConnexionResponse):
# If body in ConnexionResponse is not byte, it may not pass schema validation.
# In this case, rebuild response with aiohttp to have consistency
if response.body is None or isinstance(response.body, bytes):
return response
else:
response = cls._build_response(
data=response.body,
mimetype=mimetype,
content_type=response.content_type,
headers=response.headers,
status_code=response.status_code
)
return response

if not cls._is_framework_response(response):
response = cls._response_from_handler(response, mimetype)
Expand Down Expand Up @@ -430,27 +416,9 @@ def _prepare_body_and_status_code(cls, data, mimetype, status_code=None, extra_c
return body, status_code, mimetype

@classmethod
@abc.abstractmethod
def _serialize_data(cls, data, mimetype):
# TODO: Harmonize with flask_api. Currently this is the backwards compatible with aiohttp_api._cast_body.
if not isinstance(data, bytes):
if isinstance(mimetype, str) and is_json_mimetype(mimetype):
body = cls.jsonifier.dumps(data)
elif isinstance(data, str):
body = data
else:
warnings.warn(
"Implicit (aiohttp) serialization with str() will change in the next major version. "
"This is triggered because a non-JSON response body is being stringified. "
"This will be replaced by something that is mimetype-specific and may "
"serialize some things as JSON or throw an error instead of silently "
"stringifying unknown response bodies. "
"Please make sure to specify media/mime types in your specs.",
FutureWarning # a Deprecation targeted at application users.
)
body = str(data)
else:
body = data
return body, mimetype
pass

def json_loads(self, data):
return self.jsonifier.loads(data)
Expand Down
Loading