Skip to content

Commit

Permalink
Merge pull request #17 from verkada/revert-16-jackkeane/fix-query-par…
Browse files Browse the repository at this point in the history
…sing

Revert "Fix bug where query parameter string could get parsed as number"
  • Loading branch information
jakeane authored Oct 22, 2024
2 parents 48384d0 + c2d5ee9 commit aaf1f0d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions flask_pydantic_spec/flask_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions flask_pydantic_spec/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aaf1f0d

Please sign in to comment.