Skip to content

Commit 7665fda

Browse files
authored
Fix UserWarning on Flask 2.2.0 (#500)
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: #485 Signed-off-by: Jonathan Dieter <[email protected]> Signed-off-by: Jonathan Dieter <[email protected]>
1 parent f6709d9 commit 7665fda

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

flask_restx/api.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ def init_app(self, app, **kwargs):
229229
self.license_url = kwargs.get("license_url", self.license_url)
230230
self.url_scheme = kwargs.get("url_scheme", self.url_scheme)
231231
self._add_specs = kwargs.get("add_specs", True)
232+
self._register_specs(app)
233+
self._register_doc(app)
232234

233235
# If app is a blueprint, defer the initialization
234236
try:
@@ -245,9 +247,6 @@ def _init_app(self, app):
245247
246248
:param flask.Flask app: The flask application object
247249
"""
248-
self._register_specs(self.blueprint or app)
249-
self._register_doc(self.blueprint or app)
250-
251250
app.handle_exception = partial(self.error_router, app.handle_exception)
252251
app.handle_user_exception = partial(
253252
self.error_router, app.handle_user_exception

0 commit comments

Comments
 (0)