-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
Refactor decorators #1618
Refactor decorators #1618
Conversation
0e7faef
to
de3b6f6
Compare
Pull Request Test Coverage Report for Build 3833178906
💛 - Coveralls |
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.
Self-review
|
||
MODULE_PATH = pathlib.Path(__file__).absolute().parent.parent | ||
SWAGGER_UI_URL = "ui" | ||
|
||
logger = logging.getLogger("connexion.apis.abstract") | ||
|
||
|
||
class AbstractAPIMeta(abc.ABCMeta): |
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.
Don't see a reason for this to be a Metaclass. I would still like to rework how the jsonifier is defined and passed around.
@@ -41,7 +41,7 @@ def wrapped_default(self, o): | |||
if isinstance(o, uuid.UUID): | |||
return str(o) | |||
|
|||
return default_fn(o) | |||
return default_fn(self, o) |
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.
We're wrapping a method.
@@ -243,45 +228,20 @@ def get_mimetype(self): | |||
return DEFAULT_MIMETYPE | |||
|
|||
@property | |||
def _uri_parsing_decorator(self): | |||
def uri_parser_class(self): |
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.
Would prefer not to pass this via the operation. We can probably handle it similarly to the Jsonifier.
|
||
# TODO: don't default | ||
produces = list(set(self.operation.produces)) | ||
if data is not None and not produces: |
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.
This keeps backward compatibility, although I don't think we should. We should expect the spec to define a content type when a response is returned.
https://swagger.io/specification/v2/#responseObject
- A missing response schema defines an empty response
- If a response schema is present, produces should be defined
In OpenAPI 3, a response cannot be defined without its content type.
@@ -139,7 +139,12 @@ def test_pass_through(simple_app): | |||
app_client = simple_app.app.test_client() | |||
|
|||
response = app_client.get("/v1.0/multimime", data={}) # type: flask.Response | |||
assert response.status_code == 200 | |||
assert response.status_code == 500 | |||
assert ( |
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.
This is a change of behavior. If the spec defines multiple content types, we should not guess.
@@ -1,67 +1,116 @@ | |||
from unittest.mock import MagicMock | |||
|
|||
from connexion.decorators.parameter import parameter_to_arg, pythonic | |||
from connexion.decorators.parameter import ( |
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.
Test both Sync & Async decorator. Refactored to work with new decorators.
This PR refactors the decorators so they can be used independently of an API, which will allow them to be used by other wrapped frameworks as well.