Browse Source

update error message for query parameter type handling

pull/14479/head
Anton.D 7 months ago
parent
commit
cf4b822681
  1. 2
      fastapi/dependencies/utils.py
  2. 8
      tests/test_invalid_sequence_param.py

2
fastapi/dependencies/utils.py

@ -552,7 +552,7 @@ def analyze_param(
# For Pydantic v1
and getattr(field, "shape", 1) == 1
)
), f"Query param {param_name!r} must be of one of the supported types"
), f"Query parameter {param_name!r} must be one of the supported types"
return ParamDetails(type_annotation=type_annotation, depends=depends, field=field)

8
tests/test_invalid_sequence_param.py

@ -8,7 +8,7 @@ from pydantic import BaseModel
def test_invalid_sequence():
with pytest.raises(
AssertionError,
match="Query param 'q' must be of one of the supported types",
match="Query parameter 'q' must be one of the supported types",
):
app = FastAPI()
@ -23,7 +23,7 @@ def test_invalid_sequence():
def test_invalid_tuple():
with pytest.raises(
AssertionError,
match="Query param 'q' must be of one of the supported types",
match="Query parameter 'q' must be one of the supported types",
):
app = FastAPI()
@ -38,7 +38,7 @@ def test_invalid_tuple():
def test_invalid_dict():
with pytest.raises(
AssertionError,
match="Query param 'q' must be of one of the supported types",
match="Query parameter 'q' must be one of the supported types",
):
app = FastAPI()
@ -53,7 +53,7 @@ def test_invalid_dict():
def test_invalid_simple_dict():
with pytest.raises(
AssertionError,
match="Query param 'q' must be of one of the supported types",
match="Query parameter 'q' must be one of the supported types",
):
app = FastAPI()

Loading…
Cancel
Save