-
Notifications
You must be signed in to change notification settings - Fork 154
Adds support for marshmallow @post_load
#119
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adds support for marshmallow @post_load
#119
Conversation
Marshmallow `@post_load` decorator can be used as a factory object, to directly return an instance instead of the usual dictionary. This commit adds support for it.
Codecov Report
@@ Coverage Diff @@
## master #119 +/- ##
==========================================
+ Coverage 97.64% 97.65% +0.01%
==========================================
Files 8 8
Lines 339 341 +2
==========================================
+ Hits 331 333 +2
Misses 8 8
Continue to review full report at Codecov.
|
Any chance this could be merged? It looks like a pretty common problem... |
Can this be merged ? we are also hitting this. |
When it will be merged? |
Sorry for the delay on this. I can take a look and release this over the weekend. |
@sloria Thanks ! |
flask_apispec/wrapper.py
Outdated
@@ -43,8 +43,11 @@ def call_view(self, *args, **kwargs): | |||
parsed = parser.parse(schema, locations=option['kwargs']['locations']) | |||
if getattr(schema, 'many', False): | |||
args += tuple(parsed) | |||
else: | |||
elif getattr(parsed, 'update', False): |
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.
There is risk of a false-positive here, e.g. model objects with an update
method, so I think type-checking is preferable to duck-typing in this case.
I'll make this change myself.
Fixes #103
Marshmallow
@post_load
decorator can be used as an object factory, to directly return an instance instead of the usual dictionary.This PR adds support for it, based on #104 plus tests.