Skip to content

Commit 49e180d

Browse files
author
daniel
committed
rename ERROR_404_HELP -> RESTX_ERROR_404_HELP (fixes #114)
1 parent 4193577 commit 49e180d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

doc/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ You can also match parts of the path as variables to your resource methods.
202202
If a request does not match any of your application's endpoints,
203203
Flask-RESTX will return a 404 error message with suggestions of other
204204
endpoints that closely match the requested endpoint.
205-
This can be disabled by setting ``ERROR_404_HELP`` to ``False`` in your application config.
205+
This can be disabled by setting ``RESTX_ERROR_404_HELP`` to ``False`` in your application config.
206206
207207
208208
Argument Parsing

flask_restx/api.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
import six
1111
import sys
12+
import warnings
1213

1314
from collections import OrderedDict
1415
from functools import wraps, partial
@@ -219,6 +220,7 @@ def init_app(self, app, **kwargs):
219220
else:
220221
self.blueprint = app
221222

223+
222224
def _init_app(self, app):
223225
"""
224226
Perform initialization actions with the given :class:`flask.Flask` object.
@@ -250,6 +252,16 @@ def _init_app(self, app):
250252
app.config.setdefault("RESTX_MASK_SWAGGER", True)
251253
app.config.setdefault("RESTX_INCLUDE_ALL_MODELS", False)
252254

255+
# check for deprecated config variable names
256+
if "ERROR_404_HELP" in app.config:
257+
app.config['RESTX_ERROR_404_HELP'] = app.config['ERROR_404_HELP']
258+
warnings.warn(
259+
"'ERROR_404_HELP' config setting is deprecated and will be "
260+
"removed in the future. Use 'RESTX_ERROR_404_HELP' instead.",
261+
DeprecationWarning
262+
)
263+
264+
253265
def __getattr__(self, name):
254266
try:
255267
return getattr(self.default_namespace, name)
@@ -709,7 +721,7 @@ def handle_error(self, e):
709721

710722
elif (
711723
code == HTTPStatus.NOT_FOUND
712-
and current_app.config.get("ERROR_404_HELP", True)
724+
and current_app.config.get("RESTX_ERROR_404_HELP", True)
713725
and include_message_in_response
714726
):
715727
data["message"] = self._help_on_404(data.get("message", None))

tests/test_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def test_handle_smart_errors(self, app):
480480
assert response.status_code == 404
481481
assert "did you mean /foo ?" in response.data.decode()
482482

483-
app.config["ERROR_404_HELP"] = False
483+
app.config["RESTX_ERROR_404_HELP"] = False
484484

485485
response = api.handle_error(NotFound())
486486
assert response.status_code == 404

0 commit comments

Comments
 (0)