You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
While using the @validate decorator on a class-based view, I get the following exception:
[...]python/site-packages/sanic_ext/extras/validation/decorator.py", line 39, in decorated_function
data=request.json,
AttributeError: 'SomeResource' object has no attribute 'json'
And this is how my Class Based view look like:
class SomeResource(HTTPMethodView):
@validate(json=ResourceSchema)
async def post(self, request):
pass
Additional Notes
Diving quickly into the code of the decorator, it seems like we are not handling the class case of the views, where the first argument of the method is the class instance and not the request instance (like in the function-based view):
I think a solution for that can be to use the kwargs rather than the position, but I am not too familiar with the codebase just yet, so there might be a more suitable solution for this repo.
The text was updated successfully, but these errors were encountered:
Describe the bug
While using the
@validate
decorator on a class-based view, I get the following exception:And this is how my Class Based view look like:
Additional Notes
Diving quickly into the code of the decorator, it seems like we are not handling the class case of the views, where the first argument of the method is the class instance and not the request instance (like in the function-based view):
I think a solution for that can be to use the kwargs rather than the position, but I am not too familiar with the codebase just yet, so there might be a more suitable solution for this repo.
The text was updated successfully, but these errors were encountered: