From c2d5ee93f2c90f9decc0ea7fe68f5f39815fec0f Mon Sep 17 00:00:00 2001 From: Jack Keane <52009851+jakeane@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:42:39 -0700 Subject: [PATCH] Revert "Fix bug where query parameter string could get parsed as number" --- flask_pydantic_spec/flask_backend.py | 4 +--- flask_pydantic_spec/utils.py | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/flask_pydantic_spec/flask_backend.py b/flask_pydantic_spec/flask_backend.py index b5695fe..d10fa12 100644 --- a/flask_pydantic_spec/flask_backend.py +++ b/flask_pydantic_spec/flask_backend.py @@ -151,9 +151,7 @@ def request_validation( {} if request.get_data() == b"" else request.get_json(force=True) ) elif request.content_type and "multipart/form-data" in request.content_type: - parsed_body = ( - parse_multi_dict(request.form, parse_json=True) if request.form else {} - ) + parsed_body = parse_multi_dict(request.form) if request.form else {} else: parsed_body = request.get_data() or {} req_headers: Optional[Headers] = request.headers or None diff --git a/flask_pydantic_spec/utils.py b/flask_pydantic_spec/utils.py index 028f478..2e38c31 100644 --- a/flask_pydantic_spec/utils.py +++ b/flask_pydantic_spec/utils.py @@ -197,16 +197,14 @@ def default_after_handler( ) -def parse_multi_dict(input: MultiDict, parse_json: bool = False) -> Dict[str, Any]: +def parse_multi_dict(input: MultiDict) -> Dict[str, Any]: result = {} for key, value in input.to_dict(flat=False).items(): - if len(value) == 1 and parse_json: + if len(value) == 1: try: value_to_use = json.loads(value[0]) except (TypeError, JSONDecodeError): value_to_use = value[0] - elif len(value) == 1: - value_to_use = value[0] else: value_to_use = value result[key] = value_to_use