Skip to content
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

Merged
merged 15 commits into from
Apr 4, 2017
Merged

Conversation

dutradda
Copy link
Contributor

@dutradda dutradda commented Feb 1, 2017

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

@dutradda
Copy link
Contributor Author

dutradda commented Feb 1, 2017

the tests envs with -dev option are breaking and I dont know why..
the error says that a site-packages/six-1.10.0.dist-info/METADATA is missing.
In my machine I created this files by hand and all tests are passing.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7671ea3 on dutradda:frameworks_passing into 8e10a77 on zalando:master.

@rafaelcaricio
Copy link
Collaborator

@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.

@dutradda
Copy link
Contributor Author

@rafaelcaricio any progress on this?

@rafaelcaricio
Copy link
Collaborator

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?

@rafaelcaricio
Copy link
Collaborator

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)
Copy link
Collaborator

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?

@coveralls
Copy link

coveralls commented Feb 14, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling ad8a3b5 on dutradda:frameworks_passing into fe6a625 on zalando:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ad8a3b5 on dutradda:frameworks_passing into fe6a625 on zalando:master.

Copy link
Collaborator

@rafaelcaricio rafaelcaricio left a 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.

@@ -47,22 +46,17 @@ def compatibility_layer(spec):
return spec


def canonical_base_url(base_path):
@six.add_metaclass(abc.ABCMeta)
class AbstractApi(object):
Copy link
Collaborator

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.

"""
Make given "basePath" a canonical base URL which can be prepended to paths starting with "/".
Single Abstract API
Copy link
Collaborator

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 ..."


@abc.abstractmethod
def add_swagger_json(self):
""""""
Copy link
Collaborator

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.


@abc.abstractmethod
def add_auth_on_not_found(self, security, security_definitions):
""""""
Copy link
Collaborator

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.


@abc.abstractmethod
def add_swagger_ui(self):
""""""
Copy link
Collaborator

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.

http_server.serve_forever()
else:
raise Exception('Server %s not recognized', self.server)
""""""
Copy link
Collaborator

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can ignore this.

@@ -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'"')
Copy link
Collaborator

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?

data = json.dumps(data)
data = json.loads(data)
data = data.replace(b'\\"', b'"')
data = self.operation.api.jsonifier.loads(data)
Copy link
Collaborator

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.

except NonConformingResponseHeaders as e:
return problem(500, e.reason, e.message)
response = problem(500, e.reason, e.message)
Copy link
Collaborator

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:
   ...

?

@rafaelcaricio
Copy link
Collaborator

This work is related to #380

@lasomethingsomething
Copy link
Contributor

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

@dutradda
Copy link
Contributor Author

@rafaelcaricio I did the changes you request
@LappleApple Thanks for appreciating! I am exciting too! This is my first big contribution to a free software project.
Thanks all of you guys

@coveralls
Copy link

coveralls commented Mar 14, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 2699c36 on dutradda:frameworks_passing into e9db7fe on zalando:master.

@coveralls
Copy link

coveralls commented Mar 16, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 225eeae on dutradda:frameworks_passing into e9db7fe on zalando:master.

@coveralls
Copy link

coveralls commented Mar 16, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 220d93a on dutradda:frameworks_passing into d1df8f6 on zalando:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 35cd831 on dutradda:frameworks_passing into d1df8f6 on zalando:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 35cd831 on dutradda:frameworks_passing into d1df8f6 on zalando:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 35cd831 on dutradda:frameworks_passing into d1df8f6 on zalando:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 35cd831 on dutradda:frameworks_passing into d1df8f6 on zalando:master.

@coveralls
Copy link

coveralls commented Mar 16, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 1425f53 on dutradda:frameworks_passing into d1df8f6 on zalando:master.

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.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 65bfe5a on dutradda:frameworks_passing into 711bbf0 on zalando:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 65bfe5a on dutradda:frameworks_passing into 711bbf0 on zalando:master.

@coveralls
Copy link

coveralls commented Apr 4, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 65bfe5a on dutradda:frameworks_passing into 711bbf0 on zalando:master.

@coveralls
Copy link

coveralls commented Apr 4, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 719f685 on dutradda:frameworks_passing into 711bbf0 on zalando:master.

1 similar comment
@coveralls
Copy link

coveralls commented Apr 4, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 719f685 on dutradda:frameworks_passing into 711bbf0 on zalando:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 56e6197 on dutradda:frameworks_passing into 711bbf0 on zalando:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 56e6197 on dutradda:frameworks_passing into 711bbf0 on zalando:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 56e6197 on dutradda:frameworks_passing into 711bbf0 on zalando:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 56e6197 on dutradda:frameworks_passing into 711bbf0 on zalando:master.

@rafaelcaricio
Copy link
Collaborator

👍

@rafaelcaricio rafaelcaricio merged commit 53908d3 into spec-first:master Apr 4, 2017
@dutradda
Copy link
Contributor Author

dutradda commented Apr 4, 2017

@rafaelcaricio today is my birthday, is a great gift for me!
I changed the setup.py to install flask just optionally, so would be interesting to warn in README or something like this

@rafaelcaricio
Copy link
Collaborator

@dutradda Well, feliz aniversário! 🎂 🎈

Well thought, I will add a note in the README for that. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants