flask-rest-jsonapi
flask-rest-jsonapi copied to clipboard
afer 0.27.0 decorators supplied through Api.__init__ no longer work
Following code:
from flask_rest_jsonapi import Api
from flask_jwt_extended import jwt_required
api = Api(decorators=(jwt_required,))
no longer causes JWT validation meaning I'm able to access endpoints with or without JWT.
Documentation still claims it should work.
In 0c212bd71e9f46ab633d93703bc29c1009222554 we see that using supplied decorators is removed but it is not clear why.
- What is alternative way of decorating all endpoints with one or more decorators?
- Can you please document this or at least remove no longer true docs from
api.rst
?
Indeed, that commit should be reverted unless there is a good alternative.
One alternative is to register the Api()
as a blueprint and apply a decorator to before_request
:
bp = Blueprint("api", __name__)
@bp.before_request
@decorator
def before_request():
""" Apply decorator to all endpoints. """
pass
api = Api(app, bp)
https://stackoverflow.com/questions/37323089/how-to-apply-decorator-to-all-blueprint-urls-in-flask
Any follow ups. It will be good just to remove it form documentaiton if it not plan to support it