Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ You can also match parts of the path as variables to your resource methods.
If a request does not match any of your application's endpoints,
Flask-RESTX will return a 404 error message with suggestions of other
endpoints that closely match the requested endpoint.
This can be disabled by setting ``ERROR_404_HELP`` to ``False`` in your application config.
This can be disabled by setting ``RESTX_ERROR_404_HELP`` to ``False`` in your application config.


Argument Parsing
Expand Down
14 changes: 13 additions & 1 deletion flask_restx/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import six
import sys
import warnings

from collections import OrderedDict
from functools import wraps, partial
Expand Down Expand Up @@ -219,6 +220,7 @@ def init_app(self, app, **kwargs):
else:
self.blueprint = app


def _init_app(self, app):
"""
Perform initialization actions with the given :class:`flask.Flask` object.
Expand Down Expand Up @@ -250,6 +252,16 @@ def _init_app(self, app):
app.config.setdefault("RESTX_MASK_SWAGGER", True)
app.config.setdefault("RESTX_INCLUDE_ALL_MODELS", False)

# check for deprecated config variable names
if "ERROR_404_HELP" in app.config:
app.config['RESTX_ERROR_404_HELP'] = app.config['ERROR_404_HELP']
warnings.warn(
"'ERROR_404_HELP' config setting is deprecated and will be "
"removed in the future. Use 'RESTX_ERROR_404_HELP' instead.",
DeprecationWarning
)


def __getattr__(self, name):
try:
return getattr(self.default_namespace, name)
Expand Down Expand Up @@ -709,7 +721,7 @@ def handle_error(self, e):

elif (
code == HTTPStatus.NOT_FOUND
and current_app.config.get("ERROR_404_HELP", True)
and current_app.config.get("RESTX_ERROR_404_HELP", True)
and include_message_in_response
):
data["message"] = self._help_on_404(data.get("message", None))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def test_handle_smart_errors(self, app):
assert response.status_code == 404
assert "did you mean /foo ?" in response.data.decode()

app.config["ERROR_404_HELP"] = False
app.config["RESTX_ERROR_404_HELP"] = False

response = api.handle_error(NotFound())
assert response.status_code == 404
Expand Down