From 7b93177cef00af11a07a68e351206865e8429a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=A9na=C3=ABl=20Muller?= Date: Thu, 6 Jun 2019 17:23:03 +0200 Subject: [PATCH] do not check body in pyramid context --- hapic/ext/pyramid/context.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hapic/ext/pyramid/context.py b/hapic/ext/pyramid/context.py index f7aa1b5..79472f2 100644 --- a/hapic/ext/pyramid/context.py +++ b/hapic/ext/pyramid/context.py @@ -50,9 +50,14 @@ def get_request_parameters(self, *args, **kwargs) -> RequestParameters: req = args[-1] # TODO : Check # TODO : move this code to check_json # same idea as in : https://bottlepy.org/docs/dev/_modules/bottle.html#BaseRequest.json - if req.body and req.content_type in ("application/json", "application/json-rpc"): - json_body = req.json_body - # TODO : raise exception if not correct , return 400 if uncorrect instead ? + if req.content_type in ("application/json", "application/json-rpc"): + try: + json_body = req.json_body + # TODO - G.M - 2019-06-06 - raise exception if not correct , + # return 400 if uncorrect instead ? + except Exception: + json_body = {} + else: json_body = {}