Starting with Flask version 2.2.0, there's a UserWarning raised for Blueprint. It will raise an exception in 2.3.0. With Flask 2.1.3, there's no warning.
Code
from flask import Flask, Blueprint
from flask_restx import Api
app = Flask(__name__)
api_bp = Blueprint('api', __name__)
api = Api(api_bp)
app.register_blueprint(api_bp, url_prefix="/api")
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
Repro Steps (if applicable)
Create a basic API with code provided
Run the code
Check output
Expected Behavior
flask-restx should use Flask method properly to prevent it from getting broken in future.
Actual Behavior
Flask raise UserWarning.
Error Messages/Stack Trace
/Users/morpheus/Desktop/flask-restx-issue/venv/lib/python3.10/site-packages/flask_restx/api.py:322: UserWarning: The setup method 'add_url_rule' can no longer be called on the blueprint 'api'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
app_or_blueprint.add_url_rule(self._doc, "doc", self.render_doc)
/Users/morpheus/Desktop/flask-restx-issue/venv/lib/python3.10/site-packages/flask/blueprints.py:490: UserWarning: The setup method 'record' can no longer be called on the blueprint 'api'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
self.record(
/Users/morpheus/Desktop/flask-restx-issue/venv/lib/python3.10/site-packages/flask_restx/api.py:323: UserWarning: The setup method 'add_url_rule' can no longer be called on the blueprint 'api'. It has already been registered at least once, any changes will not be applied consistently.
Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.
This warning will become an exception in Flask 2.3.
app_or_blueprint.add_url_rule(self.prefix or "/", "root", self.render_root)
Environment
Python version 3.10.2
Flask version 2.2.2
Flask-RESTX version 1.0.3
Other installed Flask extensions
Additional Context
This is your last chance to provide any pertinent details, don't let this opportunity pass you by!
Starting with Flask version 2.2.0, there's a UserWarning raised for Blueprint. It will raise an exception in 2.3.0. With Flask 2.1.3, there's no warning.
Code
Repro Steps (if applicable)
Expected Behavior
flask-restx should use Flask method properly to prevent it from getting broken in future.
Actual Behavior
Flask raise UserWarning.
Error Messages/Stack Trace
Environment
Additional Context
This is your last chance to provide any pertinent details, don't let this opportunity pass you by!