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

Added an api module, implements #107 #111

Merged
merged 6 commits into from
Jun 30, 2019
Merged

Added an api module, implements #107 #111

merged 6 commits into from
Jun 30, 2019

Conversation

volfpeter
Copy link
Contributor

Added an api module, that contains:

  • API: The base class to extend to document routes using a class-based syntax and possibly a single decorator. See its documentation for a proper description and example usage.
  • Response: Helper class that is required by API to support doc.response().

@chenjr0719
Copy link
Member

@volfpeter I will review this PR after #109 is done if you don't mind. I want to make standard test cases for this project first.
Before that, is it possible to add tests for this PR? I feel a little unsafe to put this into project without tests.

@volfpeter
Copy link
Contributor Author

Sure, it's a good idea. I'll have a look at the current test cases to see how I can write some for this module.
Also, if you have any questions regarding the api module, please let me know. I know it's a quite large addition to the project and it requires a thorough review.

@volfpeter
Copy link
Contributor Author

I've added tests for the api module (160+ lines, much more than all other tests combined).

  • test_message_api_response() basically checks the decorators class attribute's implementation.
  • test_documentation() compares the resulting swagger.json to a benchmark swagger.json (tests create an app with api-based docs and a benchmark app with doc-based docs).

api code coverage is 70% right now. Here is a list of things that are not tested yet:

  • The exclude class attribute.
  • Routing methods except post().
  • Inline overrides in the decorator (like MessageAPI(consumes_content_type="application/xml", tag="xml") \ def foo(request): ...).

@ahopkins
Copy link
Member

@volfpeter Can you run git rebase -i (or some other method) to squash your commits into a single?

@volfpeter
Copy link
Contributor Author

For the record, since my previous comment, I've added tests for:

  • The exclude class attribute.
  • All routing methods.
  • Inline override for the exclude class attribute.

Code coverage is over 90% after these changes, but of course there are plenty of things that could still be tested.

@volfpeter
Copy link
Contributor Author

@chenjr0719 What is the status of this PR? Do you have an estimate when it could get a review?

@volfpeter
Copy link
Contributor Author

@chenjr0719 Hi! Could you please give an estimate when this PR might get reviewed?

@chenjr0719
Copy link
Member

@volfpeter Sorry about no response. I think I can get this done at the end of this Friday. Little busy recent days.

@volfpeter
Copy link
Contributor Author

Thanks. No problem! I just wanted to get some feedback on how things are going.

chenjr0719
chenjr0719 previously approved these changes Jun 27, 2019
Copy link
Member

@chenjr0719 chenjr0719 left a comment

Choose a reason for hiding this comment

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

@volfpeter This PR really impressed me because of the readability and the nice implementation(especially about the partial func part). Very appreciated for your contribution.

But it seems not passed all unit tests which I added in #109. This is not your problem, and I will create an issue about it later. To get this PR merged, could you do me a favor to skip the following test?
https://github.com/huge-success/sanic-openapi/blob/cbf0f5b27fb6b56be048a8ef020b0082ac484543/tests/test_swagger.py#L56-L66

@volfpeter
Copy link
Contributor Author

@chenjr0719 I've marked the test as skipped.

Thanks for the review and for accepting a whole new module into your project! I'm really happy to have contributed here.

One thing I miss a bit is a readme update. Should i do it? I didn't want to start editing the readme without permission or guidance on where you would like to have info about the api module...

@chenjr0719
Copy link
Member

@volfpeter Actually, I would like to create a new document of this project with mkdocs and hosted on readthedocs. This will not only include how-to document but also include all API reference with your awesome works. But this might not be ready in recent days(at least after two weekends). So, I suggest that you can put the document at README or somewhere(e.g., docs/api_module.md) if you feel comfortable.

@volfpeter
Copy link
Contributor Author

That's great! In this case, I'll leave everthing as it is right now, but please let me know if you need help writing documentation for this module. I'd be happy to help.

Copy link
Member

@chenjr0719 chenjr0719 left a comment

Choose a reason for hiding this comment

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

@ahopkins I think this PR is ready to merge.

@codecov-io
Copy link

Codecov Report

Merging #111 into master will decrease coverage by 1.53%.
The diff coverage is 87.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
- Coverage    96.8%   95.27%   -1.54%     
==========================================
  Files           3        4       +1     
  Lines         313      423     +110     
  Branches       68       87      +19     
==========================================
+ Hits          303      403     +100     
  Misses          6        6              
- Partials        4       14      +10
Impacted Files Coverage Δ
sanic_openapi/api.py 87.27% <87.27%> (ø)
sanic_openapi/doc.py 100% <0%> (+2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 462bc59...ab07636. Read the comment docs.

1 similar comment
@codecov-io
Copy link

codecov-io commented Jun 28, 2019

Codecov Report

Merging #111 into master will decrease coverage by 1.53%.
The diff coverage is 87.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
- Coverage    96.8%   95.27%   -1.54%     
==========================================
  Files           3        4       +1     
  Lines         313      423     +110     
  Branches       68       87      +19     
==========================================
+ Hits          303      403     +100     
  Misses          6        6              
- Partials        4       14      +10
Impacted Files Coverage Δ
sanic_openapi/api.py 87.27% <87.27%> (ø)
sanic_openapi/doc.py 100% <0%> (+2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 462bc59...ab07636. Read the comment docs.

@ahopkins ahopkins merged commit c79a0b3 into sanic-org:master Jun 30, 2019
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