Converged on webargs behavior for @use_kwargs and @use_args decorators#152
Converged on webargs behavior for @use_kwargs and @use_args decorators#152rusnyder wants to merge 1 commit intojmcarp:masterfrom
Conversation
| raise Exception("@use_kwargs cannot be used with a with a " | ||
| "'many=True' schema, as it must deserialize " | ||
| "to a dict") | ||
| elif isinstance(schema, ma.Schema): |
There was a problem hiding this comment.
NOTE: What follows here is entirely to provide more informative error output, since this now shares the same failure cases as webargs which may break some existing code that uses flask-apispec. My thought here was to be as helpful as possible in transition, but knowing that this adds nothing functional, I'm not sure if the value add is worth it.
At the judgement of the maintainer, I'd be okay doing one of 3 things:
- Leaving this code as is
- Rewriting to only run on failure (i.e. -
excepton the expected failures and just provide a better error message) - Remove this block entirely
a1048d7 to
4d1a8bf
Compare
Codecov Report
@@ Coverage Diff @@
## master #152 +/- ##
==========================================
+ Coverage 97.68% 97.91% +0.23%
==========================================
Files 8 8
Lines 345 383 +38
==========================================
+ Hits 337 375 +38
Misses 8 8
Continue to review full report at Codecov.
|
|
I haven't reviewed the code fully, but I do agree with the idea of bringing flask-apispec's behavior in line with it's underlying libraries. I am not sure how breaking changes are handled for this project though. @sloria What are your thoughts on these changes? |
Description
WARNING: This PR contains a breaking change to the
@use_kwargsdecorator. I believe this is a good direction for this library to go, but proceed reviewing/merging with cautionThis PR attempts to bring the
@use_kwargsand@use_argsdecorators to be more inline with the inherited Flask webargs implementations by delegating directly to them instead of mimicking their behavior.Changes:
@use_argsdecoratorwebargs.FlaskParser.use_kwargsunder the hood, so behavior should exactly match Flask webargs@use_kwargsimplementation to directly invokewebargs.FlaskParser.use_kwargs**kwargsin the view function)@use_kwargs(Schema(many=True)), as this is not supported by webargs and is now better supported by the@use_argsdecoratorFixes
TODO