-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Frameworks passing #394
Frameworks passing #394
Conversation
the tests envs with -dev option are breaking and I dont know why.. |
@dutradda Muito obrigado pelo seu PullRequest! I will start reviewing it ASAP. About the failing tests, we can take a look at this part after the code review. |
@rafaelcaricio any progress on this? |
Hi @dutradda, It is a big PR. But I am trying to find time this week to do the review. It cleaned up some checks that I think do not make sense from the codacy bot and left the ones I think should be tackled. Could you please start by those two? |
Note to self: I have to fix up the configuration of the codacy bot. |
@@ -153,7 +142,26 @@ def __init__(self, specification, base_url=None, arguments=None, | |||
self.add_paths() | |||
|
|||
if auth_all_paths: | |||
self.add_auth_on_not_found() | |||
self.add_auth_on_not_found(self.security, self.security_definitions) |
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.
What do you think about in the original method to add *args, **kwargs
just to signal that it might have arguments in the subclasses?
ce21065
to
ad8a3b5
Compare
1 similar comment
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.
@dutradda I have done a quick review. Please take a look on what I have commented. Thank you for working on this.
connexion/apis/abstract.py
Outdated
@@ -47,22 +46,17 @@ def compatibility_layer(spec): | |||
return spec | |||
|
|||
|
|||
def canonical_base_url(base_path): | |||
@six.add_metaclass(abc.ABCMeta) | |||
class AbstractApi(object): |
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.
I would suggest to change the name to AbstractAPI
.
connexion/apis/abstract.py
Outdated
""" | ||
Make given "basePath" a canonical base URL which can be prepended to paths starting with "/". | ||
Single Abstract API |
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.
Could you please describe in high level what is this class responsible for? "Defines an abstract interface for ..."
connexion/apis/abstract.py
Outdated
|
||
@abc.abstractmethod | ||
def add_swagger_json(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 be nice to have documented here what the implementations of this method are expected to do.
connexion/apis/abstract.py
Outdated
|
||
@abc.abstractmethod | ||
def add_auth_on_not_found(self, security, security_definitions): | ||
"""""" |
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 be nice to have documented here what the implementations of this method are expected to do.
connexion/apis/abstract.py
Outdated
|
||
@abc.abstractmethod | ||
def add_swagger_ui(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 be nice to have documented here what the implementations of this method are expected to do.
connexion/apps/abstract.py
Outdated
http_server.serve_forever() | ||
else: | ||
raise Exception('Server %s not recognized', self.server) | ||
"""""" |
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 be nice to have documented here what the implementations of this method are expected to do.
|
||
|
||
class FlaskJSONEncoder(json.JSONEncoder): | ||
def default(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.
You can ignore this.
connexion/decorators/response.py
Outdated
@@ -44,10 +43,10 @@ def validate_response(self, data, status_code, headers): | |||
try: | |||
# For cases of custom encoders, we need to encode and decode to | |||
# transform to the actual types that are going to be returned. | |||
data = json.dumps(data) | |||
data = json.loads(data) | |||
data = data.replace(b'\\"', b'"') |
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 need to handle encoding properly. Could you please elaborate on what is the real problem here?
connexion/decorators/response.py
Outdated
data = json.dumps(data) | ||
data = json.loads(data) | ||
data = data.replace(b'\\"', b'"') | ||
data = self.operation.api.jsonifier.loads(data) |
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.
Probably we should add a top level method in the self.operation
or api
to handle this better. This something.calling.another.internal.thing
will lead us to have a headache later.
connexion/decorators/response.py
Outdated
except NonConformingResponseHeaders as e: | ||
return problem(500, e.reason, e.message) | ||
response = problem(500, e.reason, e.message) |
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.
What about:
except (NonConformingResponseBody, NonConformingResponseHeaders) as e:
...
?
This work is related to #380 |
Hi @dutradda, wondering how things are going with your work on Connexion. It's pretty exciting for us to have Mozilla contributing, and I'd like to help promote your work once it's complete. -- Zalando OSS Evangelist |
ad8a3b5
to
2699c36
Compare
@rafaelcaricio I did the changes you request |
225eeae
to
1de525f
Compare
1de525f
to
220d93a
Compare
220d93a
to
35cd831
Compare
3 similar comments
…modules. Fixed the tests
removed test_decorators and test_parameter (this test is useless now); removed the request/response containers and add new request response classes; created a abstract api class and a api flask class; derived classes will implements the get_response/get_request methods that will convert framework req/resp types to connexion req/resp types; moved the jsonifier from produces to flask api; created a abstract app class and a app flask class; changed all validators to use the ConnexionRequest instead flask request; changed the problem function to generate a ConnexionRequest; created a new user variables container called context (this is a property of ConnexionRequest). this will be passed as kwargs to all operations functions; this context is used on authentication; fixed all tests to new API; some changes that I did may not be documented in this commit.
removed test_decorators and test_parameter (this test is useless now); removed the request/response containers and add new request response classes; created a abstract api class and a api flask class; derived classes will implements the get_response/get_request methods that will convert framework req/resp types to connexion req/resp types; moved the jsonifier from produces to flask api; created a abstract app class and a app flask class; changed all validators to use the ConnexionRequest instead flask request; changed the problem function to generate a ConnexionRequest; created a new user variables container called context (this is a property of ConnexionRequest). this will be passed as kwargs to all operations functions; this context is used on authentication; fixed all tests to new API; some changes that I did may not be documented in this commit.
Documented some AbstractAPI and AbstractApp methods; Added parameters on some abstract methods; Removed useless code from ResponseValidator; Created a wrapper for api.jsonifier.loads on Operation class; Merged with master.
02ce610
to
65bfe5a
Compare
2 similar comments
1 similar comment
3 similar comments
👍 |
@rafaelcaricio today is my birthday, is a great gift for me! |
@dutradda Well, feliz aniversário! 🎂 🎈 Well thought, I will add a note in the README for that. 😉 |
Hello guys,
I am doing a PR in master because I rewrite the frameworks branch. Now all testing are passing and flask are full uncouple.
@rafaelcaricio this just a API proposal