-
-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Sanic #1250
Support Sanic #1250
Conversation
Is it ready to merge? Looks good to me |
update Sanic poc with master
@@ -11,5 +11,5 @@ | |||
"options", | |||
"head", | |||
"patch", | |||
"trace" | |||
# "trace" # FIXME: rpolli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kigawas Sanic does not support trace
. Ideas welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trace method is rather rare, do we really need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in connexion code, so we should ask them. @dtkav
@@ -11,7 +11,7 @@ | |||
logging.basicConfig(level=logging.DEBUG) | |||
|
|||
TEST_FOLDER = pathlib.Path(__file__).parent | |||
FIXTURES_FOLDER = TEST_FOLDER / 'fixtures' | |||
FIXTURES_FOLDER = TEST_FOLDER / "fixtures" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kigawas iiuc we both like black
but I'd limit this kind of changes on connexion repo :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kigawas still there are tests failing, and more should be added. |
Lots of errors like Maybe it's better to add flake8, black and mypy to make life easier |
--- a/connexion/apis/abstract.py
+++ b/connexion/apis/abstract.py
@@ -37,7 +37,8 @@ class AbstractAPI(metaclass=AbstractAPIMeta):
def __init__(self, specification, base_path=None, arguments=None,
validate_responses=False, strict_validation=False, resolver=None,
auth_all_paths=False, debug=False, resolver_error_handler=None,
- validator_map=None, pythonic_params=False, pass_context_arg_name=None, options=None):
+ validator_map=None, pythonic_params=False, pass_context_arg_name=None, options=None,
+ ):
"""
:type specification: pathlib.Path | dict
:type base_path: str | None
@@ -101,6 +102,8 @@ class AbstractAPI(metaclass=AbstractAPIMeta):
logger.debug('pass_context_arg_name: %s', pass_context_arg_name)
self.pass_context_arg_name = pass_context_arg_name
+ self.security_handler_factory = self.make_security_handler_factory(pass_context_arg_name)
+
if self.options.openapi_spec_available:
self.add_openapi_json()
self.add_openapi_yaml()
@@ -143,6 +146,11 @@ class AbstractAPI(metaclass=AbstractAPIMeta):
Adds a 404 error handler to authenticate and only expose the 404 status if the security validation pass.
"""
+ @staticmethod
+ @abc.abstractmethod
+ def make_security_handler_factory(pass_context_arg_name):
+ """ Create SecurityHandlerFactory to create all security check handlers """
+
def add_operation(self, path, method):
"""
Adds one operation to the api. Solution index d2050b1..feb095d 100644
--- a/connexion/apis/flask_api.py
+++ b/connexion/apis/flask_api.py
@@ -9,6 +9,7 @@ from connexion.handlers import AuthErrorHandler
from connexion.jsonifier import Jsonifier
from connexion.lifecycle import ConnexionRequest, ConnexionResponse
from connexion.utils import is_json_mimetype, yamldumper
+from connexion.security import FlaskSecurityHandlerFactory
from werkzeug.local import LocalProxy
logger = logging.getLogger('connexion.apis.flask_api')
@@ -16,6 +17,11 @@ logger = logging.getLogger('connexion.apis.flask_api')
class FlaskApi(AbstractAPI):
+ @staticmethod
+ def make_security_handler_factory(pass_context_arg_name):
+ """ Create default SecurityHandlerFactory to create all security check handlers """
+ return FlaskSecurityHandlerFactory(pass_context_arg_name)
+
def _set_base_path(self, base_path):
super(FlaskApi, self)._set_base_path(base_path)
self._set_blueprint()
|
We are actively using this PR and it works pretty well, but there also come several bugs like
|
I am happy to review and merge your patches, but we really need to engage with connexion folks to continue :)
|
remove aiohttp jinja2
This pr would fix most of the errors mentioned above, except one. Here is the pytest result (for only
For full log: https://gist.github.com/kigawas/b26a4905d4f7118bd70ed8c532fd2321 |
fix build error
@@ -5,3 +5,5 @@ | |||
# concrete | |||
from .flask_security_handler_factory import FlaskSecurityHandlerFactory # NOQA | |||
from .aiohttp_security_handler_factory import AioHttpSecurityHandlerFactory # NOQA | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kigawas can we remove this space?
@@ -3,8 +3,6 @@ | |||
import functools | |||
import logging | |||
|
|||
import aiohttp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kigawas can you PR this separately to the main connexion branch so that we don't mess with files we are not going to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the sanic dependencies do not include aiohttp, it's better to remove this to avoid potential import error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr proposed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I'll update later
Is this still active? |
This PR should work itself, but the maintenance of this repo is not active I guess |
Hi folks, if there is some interest in the connexion community we can continue to work on it.... |
Connexion 3.0 will support ASGI frameworks out of the box. See #1395 |
Fixes #496 .
Changes proposed in this pull request: