Browse Source

Fix parsing list of extra non-body parameters

pull/14356/head
Yurii Motov 8 months ago
parent
commit
c9a800879f
  1. 11
      fastapi/dependencies/utils.py
  2. 2
      tests/test_tutorial/test_header_param_models/test_tutorial003.py

11
fastapi/dependencies/utils.py

@ -790,9 +790,16 @@ def request_params_to_args(
processed_keys.add(alias or field.alias)
processed_keys.add(field.name)
for key, value in received_params.items():
for key in received_params.keys():
if key not in processed_keys:
params_to_process[key] = value
if hasattr(received_params, "getlist"):
value = received_params.getlist(key)
if isinstance(value, list) and (len(value) == 1):
params_to_process[key] = value[0]
else:
params_to_process[key] = value
else:
params_to_process[key] = received_params.get(key)
if single_not_embedded_field:
field_info = first_field.field_info

2
tests/test_tutorial/test_header_param_models/test_tutorial003.py

@ -77,7 +77,7 @@ def test_header_param_model_no_underscore(client: TestClient):
"user-agent": "testclient",
"save-data": "true",
"if-modified-since": "yesterday",
"x-tag": "two",
"x-tag": ["one", "two"],
},
}
)

Loading…
Cancel
Save