Skip to content

Commit 0e8cd95

Browse files
author
DustinMoriarty
authored
Merge branch 'master' into feature/specs-url-scheme
2 parents 54be656 + b0ea3be commit 0e8cd95

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

doc/marshalling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Response marshalling
77

88

99
Flask-RESTX provides an easy way to control what data you actually render in
10-
your response or expect as in input payload.
10+
your response or expect as an input payload.
1111
With the :mod:`~.fields` module, you can use whatever objects (ORM
1212
models/custom classes/etc.) you want in your resource.
1313
:mod:`~.fields` also lets you format and filter the response

doc/scaling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Multiple namespaces
1616

1717
There are many different ways to organize your Flask-RESTX app,
1818
but here we'll describe one that scales pretty well with larger apps
19-
and maintains a nice level organization.
19+
and maintains a nice level of organization.
2020

2121
Flask-RESTX provides a way to use almost the same pattern as Flask's `blueprint`.
2222
The main idea is to split your app into reusable namespaces.

flask_restx/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "0.2.1.dev"
2+
__version__ = "0.3.1.dev"
33
__description__ = (
44
"Fully featured framework for fast, easy and documented API development with Flask"
55
)

flask_restx/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def handle_error(self, e):
677677
if (
678678
not isinstance(e, HTTPException)
679679
and current_app.propagate_exceptions
680-
and not isinstance(e, tuple(self.error_handlers.keys()))
680+
and not isinstance(e, tuple(self._own_and_child_error_handlers.keys()))
681681
):
682682

683683
exc_type, exc_value, tb = sys.exc_info()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flask-restx",
3-
"version": "0.2.1.dev",
3+
"version": "0.3.1.dev",
44
"description": "Fully featured framework for fast, easy and documented API development with Flask",
55
"repository": "python-restx/flask-restx",
66
"keywords": [

tests/test_errors.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,30 @@ def handle_custom_exception(error):
653653
"message": "error",
654654
"test": "value",
655655
}
656+
657+
def test_namespace_errorhandler_with_propagate_true(self, app, client):
658+
"""Exceptions with errorhandler on a namespace should not be
659+
returned to client, even if PROPAGATE_EXCEPTIONS is set."""
660+
app.config["PROPAGATE_EXCEPTIONS"] = True
661+
api = restx.Api(app)
662+
namespace = restx.Namespace('test_namespace')
663+
api.add_namespace(namespace)
664+
665+
@namespace.route("/test/", endpoint="test")
666+
class TestResource(restx.Resource):
667+
def get(self):
668+
raise RuntimeError("error")
669+
670+
@namespace.errorhandler(RuntimeError)
671+
def handle_custom_exception(error):
672+
return {"message": str(error), "test": "value"}, 400
673+
674+
response = client.get("/test_namespace/test/")
675+
assert response.status_code == 400
676+
assert response.content_type == "application/json"
677+
678+
data = json.loads(response.data.decode("utf8"))
679+
assert data == {
680+
"message": "error",
681+
"test": "value",
682+
}

0 commit comments

Comments
 (0)