From 7214aa715f76a90e87d5b236b756e2fcfcd00e81 Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Mon, 11 Mar 2024 13:31:43 +0100 Subject: [PATCH] Fix: API - wrong object key in json response when returning errors --- api/api/routes.py | 2 +- api/tests/test_api_cli.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/api/routes.py b/api/api/routes.py index a2c3e1f..4fae7dc 100644 --- a/api/api/routes.py +++ b/api/api/routes.py @@ -49,7 +49,7 @@ def _ask(request_data, validate_captcha=True, access_key=None): access_key=access_key) ok = validator.validate() if not ok: - return jsonify(message=validator.errors), validator.http_return_code + return jsonify(errors=validator.errors), validator.http_return_code # convert amount to wei format amount_wei = Web3.to_wei(validator.amount, 'ether') diff --git a/api/tests/test_api_cli.py b/api/tests/test_api_cli.py index 608dccb..4c39641 100644 --- a/api/tests/test_api_cli.py +++ b/api/tests/test_api_cli.py @@ -59,6 +59,7 @@ def test_ask_route_parameters(self): 'tokenAddress': ERC20_TOKEN_ADDRESS }) self.assertEqual(response.status_code, 429) + self.assertIn('errors', response.get_json().keys()) if __name__ == '__main__':