From ca08d14ae3de8a454c5f5eb5ae9e7bf90a81d0d4 Mon Sep 17 00:00:00 2001 From: Luca Sbardella Date: Tue, 3 Jul 2018 18:41:52 +0100 Subject: [PATCH] message --- openapi/__init__.py | 2 +- openapi/exc.py | 2 +- tests/test_utils.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/openapi/__init__.py b/openapi/__init__.py index 384d6f2..d776a26 100644 --- a/openapi/__init__.py +++ b/openapi/__init__.py @@ -1,3 +1,3 @@ """Minimal OpenAPI asynchronous server application """ -__version__ = '0.2.1' +__version__ = '0.2.2' diff --git a/openapi/exc.py b/openapi/exc.py index ee85886..08e79d2 100644 --- a/openapi/exc.py +++ b/openapi/exc.py @@ -18,5 +18,5 @@ def __init__(self, status=None, **kw): super().__init__(**kw) reason = self.reason if isinstance(reason, str): - reason = {'error': reason} + reason = {'message': reason} self.text = dumps(reason) diff --git a/tests/test_utils.py b/tests/test_utils.py index c6885ca..e27f19d 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -14,5 +14,12 @@ def test_debug_flag(): def test_json_http_exception(): ex = JsonHttpException(status=401) assert ex.status == 401 - assert ex.text == dumps({'error': 'Unauthorized'}) + assert ex.text == dumps({'message': 'Unauthorized'}) + assert ex.headers['content-type'] == 'application/json; charset=utf-8' + + +def test_json_http_exception_reason(): + ex = JsonHttpException(status=422, reason='non lo so') + assert ex.status == 422 + assert ex.text == dumps({'message': 'non lo so'}) assert ex.headers['content-type'] == 'application/json; charset=utf-8'