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

Feature: Add other schemas to @resonds #123

Merged

Conversation

circulon
Copy link
Contributor

@circulon circulon commented Sep 17, 2024

This PR addresses several points in #17
It adds the following

  • ability to opt-in to use different schemas based on the stats code returned
  • pass-through of the status code if provided in the return statement if it does not match an alternate schema
  • filling the schema while returning a different status code than defined in @responds declaration

Cleaned up the tests and separated them into logical groups
updated the documenation for this new feature
updated werkzeug dependency based on python version

Tristan Sweeney and others added 22 commits May 20, 2021 18:06
Two bugs noticed (may not be real bugs).

When no body is present (i.e. `request.get_json()` returns `None`) the schema is presented `None` to load from, whereas an empty JSON body could better be interpreted as `{}`. For a body schema with no required fields this leads to better behavior.

Error aggregation doesn't seem to have been working correctly, as `error.data['errors']` never existed, and comment "If any parsing produced an error, combine them and reraise" hints this was the intended behavior.
Exclude lines used specifically for marshmallow compatibility
# Conflicts:
#	dev-requirements.txt
Now works with
Flask 2.2
Weukzeug 2.2
flask-restx 1.0.1
werkzeug 3.x requires python 3.8+
separated tests into logical grouping
consolidated imorts
@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 96.58887% with 19 lines in your changes missing coverage. Please review.

Project coverage is 97.03%. Comparing base (d6ce0bf) to head (eeb3a62).
Report is 37 commits behind head on master.

Files with missing lines Patch % Lines
flask_accepts/tests/test_responds.py 95.70% 14 Missing ⚠️
flask_accepts/decorators/decorators.py 91.66% 3 Missing ⚠️
flask_accepts/tests/test_accepts.py 97.97% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #123      +/-   ##
==========================================
- Coverage   98.35%   97.03%   -1.32%     
==========================================
  Files           7        9       +2     
  Lines        1154     1416     +262     
==========================================
+ Hits         1135     1374     +239     
- Misses         19       42      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@apryor6 apryor6 merged commit 6e808b8 into apryor6:master Sep 17, 2024
1 check passed
@apryor6
Copy link
Owner

apryor6 commented Sep 17, 2024

Looks great, thanks for contributing!

@apryor6
Copy link
Owner

apryor6 commented Sep 17, 2024

Available in latest version https://pypi.org/project/flask-accepts/#history

@circulon
Copy link
Contributor Author

@apryor6 Thanks for this and updating pypi

Could you also bump the setup.py and tag this new version here?

Cheers

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