From 30615c6993fcaf850c03954c45bd71890e7e3265 Mon Sep 17 00:00:00 2001 From: Taha Lukmanji Date: Thu, 5 Mar 2020 19:01:54 +0000 Subject: [PATCH 1/3] Added server_args to AbstractApp --- connexion/apps/abstract.py | 6 ++++-- connexion/apps/flask_app.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/connexion/apps/abstract.py b/connexion/apps/abstract.py index 5c9fe301b..5e0d043ad 100644 --- a/connexion/apps/abstract.py +++ b/connexion/apps/abstract.py @@ -10,7 +10,7 @@ class AbstractApp(metaclass=abc.ABCMeta): def __init__(self, import_name, api_cls, port=None, specification_dir='', - host=None, server=None, arguments=None, auth_all_paths=False, debug=None, + host=None, server=None, server_args=dict(), arguments=None, auth_all_paths=False, debug=None, resolver=None, options=None, skip_error_handlers=False): """ :param import_name: the name of the application package @@ -45,8 +45,10 @@ def __init__(self, import_name, api_cls, port=None, specification_dir='', self.options = ConnexionOptions(options) - self.app = self.create_app() self.server = server + self.server_args = server_args + self.app = self.create_app() + # we get our application root path to avoid duplicating logic self.root_path = self.get_root_path() diff --git a/connexion/apps/flask_app.py b/connexion/apps/flask_app.py index 41585a7fe..2ae02e132 100644 --- a/connexion/apps/flask_app.py +++ b/connexion/apps/flask_app.py @@ -21,7 +21,7 @@ def __init__(self, import_name, server='flask', **kwargs): super(FlaskApp, self).__init__(import_name, FlaskApi, server=server, **kwargs) def create_app(self): - app = flask.Flask(self.import_name) + app = flask.Flask(self.import_name, **self.server_args) app.json_encoder = FlaskJSONEncoder return app From dbe4ddec1301d200b3e5d465395c0c860b325565 Mon Sep 17 00:00:00 2001 From: Taha Lukmanji Date: Thu, 5 Mar 2020 19:01:54 +0000 Subject: [PATCH 2/3] Added server_args to AbstractApp --- connexion/apps/abstract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connexion/apps/abstract.py b/connexion/apps/abstract.py index 5e0d043ad..8553f9881 100644 --- a/connexion/apps/abstract.py +++ b/connexion/apps/abstract.py @@ -10,7 +10,7 @@ class AbstractApp(metaclass=abc.ABCMeta): def __init__(self, import_name, api_cls, port=None, specification_dir='', - host=None, server=None, server_args=dict(), arguments=None, auth_all_paths=False, debug=None, + host=None, server=None, server_args=None, arguments=None, auth_all_paths=False, debug=None, resolver=None, options=None, skip_error_handlers=False): """ :param import_name: the name of the application package @@ -46,7 +46,7 @@ def __init__(self, import_name, api_cls, port=None, specification_dir='', self.options = ConnexionOptions(options) self.server = server - self.server_args = server_args + self.server_args = dict() if server_args is None else server_args self.app = self.create_app() From 215e2502d4e11edcce6bfba89c84452ae69c22d3 Mon Sep 17 00:00:00 2001 From: Taha Lukmanji Date: Thu, 5 Mar 2020 19:01:54 +0000 Subject: [PATCH 3/3] Added server_args to AbstractApp * server_args are then passed to Flask aio_https constructors * Updated documentation to reflect the change --- connexion/apps/abstract.py | 7 ++++--- connexion/apps/aiohttp_app.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/connexion/apps/abstract.py b/connexion/apps/abstract.py index 5e0d043ad..bc78e02d5 100644 --- a/connexion/apps/abstract.py +++ b/connexion/apps/abstract.py @@ -10,7 +10,7 @@ class AbstractApp(metaclass=abc.ABCMeta): def __init__(self, import_name, api_cls, port=None, specification_dir='', - host=None, server=None, server_args=dict(), arguments=None, auth_all_paths=False, debug=None, + host=None, server=None, server_args=None, arguments=None, auth_all_paths=False, debug=None, resolver=None, options=None, skip_error_handlers=False): """ :param import_name: the name of the application package @@ -23,6 +23,8 @@ def __init__(self, import_name, api_cls, port=None, specification_dir='', :type specification_dir: pathlib.Path | str :param server: which wsgi server to use :type server: str | None + :param server_args: dictionary of arguments which are then passed to appropriate http server (Flask or aio_http) + :type server_args: dict | None :param arguments: arguments to replace on the specification :type arguments: dict | None :param auth_all_paths: whether to authenticate not defined paths @@ -46,9 +48,8 @@ def __init__(self, import_name, api_cls, port=None, specification_dir='', self.options = ConnexionOptions(options) self.server = server - self.server_args = server_args + self.server_args = dict() if server_args is None else server_args self.app = self.create_app() - # we get our application root path to avoid duplicating logic self.root_path = self.get_root_path() diff --git a/connexion/apps/aiohttp_app.py b/connexion/apps/aiohttp_app.py index 581fe6f78..1e3dba8bf 100644 --- a/connexion/apps/aiohttp_app.py +++ b/connexion/apps/aiohttp_app.py @@ -20,7 +20,7 @@ def __init__(self, import_name, only_one_api=False, **kwargs): self._api_added = False def create_app(self): - return web.Application() + return web.Application(**self.server_args) def get_root_path(self): mod = sys.modules.get(self.import_name)