Skip to content

Commit

Permalink
Fix UserWarning on Flask 2.2.0
Browse files Browse the repository at this point in the history
Flask 2.2.0 issues a warning if a url rule is added to a blueprint after it
has been registered, so this commit ensures that the documentation rules
are added before the blueprint is registered.

Fixes: python-restx#485

Signed-off-by: Jonathan Dieter <jonathan.dieter@spearline.com>
  • Loading branch information
jdieter committed Dec 14, 2022
1 parent 4c748d0 commit 051f83a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions flask_restx/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def init_app(self, app, **kwargs):
self.license_url = kwargs.get("license_url", self.license_url)
self.url_scheme = kwargs.get("url_scheme", self.url_scheme)
self._add_specs = kwargs.get("add_specs", True)
self._register_specs(app)
self._register_doc(app)

# If app is a blueprint, defer the initialization
try:
Expand All @@ -245,9 +247,6 @@ def _init_app(self, app):
:param flask.Flask app: The flask application object
"""
self._register_specs(self.blueprint or app)
self._register_doc(self.blueprint or app)

app.handle_exception = partial(self.error_router, app.handle_exception)
app.handle_user_exception = partial(
self.error_router, app.handle_user_exception
Expand Down

0 comments on commit 051f83a

Please sign in to comment.