From de76d16aea1e81b8836b24170f6c950b574df1af Mon Sep 17 00:00:00 2001 From: hos Date: Tue, 14 Jul 2026 15:11:32 +0100 Subject: [PATCH 1/3] Update test_tutorial001.py --- .../test_query_params/test_tutorial001.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_tutorial/test_query_params/test_tutorial001.py b/tests/test_tutorial/test_query_params/test_tutorial001.py index d68702587..2536f0ffd 100644 --- a/tests/test_tutorial/test_query_params/test_tutorial001.py +++ b/tests/test_tutorial/test_query_params/test_tutorial001.py @@ -131,3 +131,18 @@ def test_openapi_schema(client: TestClient): }, } ) + +def test_read_user_item(client: TestClient, path, expected_json): + response = client.get(path) + assert response.status_code == 200 + assert response.json() == expected_json + + +def test_invalid_query_parameter(client: TestClient): + response = client.get("/items/?skip=invalid") + + assert response.status_code == 422 + assert response.json()["detail"][0]["loc"] == ["query", "skip"] + + +def test_openapi_schema(client: TestClient): From 783595aa10f93208c387b0b7be5a16bc07da9400 Mon Sep 17 00:00:00 2001 From: hos Date: Sat, 18 Jul 2026 21:29:20 +0100 Subject: [PATCH 2/3] Clarify query parameter validation behavior --- docs/en/docs/tutorial/query-params.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/en/docs/tutorial/query-params.md b/docs/en/docs/tutorial/query-params.md index cb89e23e7..50a9d2847 100644 --- a/docs/en/docs/tutorial/query-params.md +++ b/docs/en/docs/tutorial/query-params.md @@ -20,6 +20,11 @@ http://127.0.0.1:8000/items/?skip=0&limit=10 As they are part of the URL, they are "naturally" strings. But when you declare them with Python types (in the example above, as `int`), they are converted to that type and validated against it. +For example, if `skip` is declared as an `int`, sending a value that cannot be converted to an integer: +``` +http://127.0.0.1:8000/items/?skip=abc +``` +will result in a validation error because `"abc"` cannot be converted to an integer. All the same processes that apply to path parameters also apply to query parameters: From 7be32447e65bec9e86f180867586bcd22aaf0611 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 18 Jul 2026 20:30:35 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/tutorial/query-params.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/docs/tutorial/query-params.md b/docs/en/docs/tutorial/query-params.md index 50a9d2847..a34cc7c49 100644 --- a/docs/en/docs/tutorial/query-params.md +++ b/docs/en/docs/tutorial/query-params.md @@ -20,7 +20,7 @@ http://127.0.0.1:8000/items/?skip=0&limit=10 As they are part of the URL, they are "naturally" strings. But when you declare them with Python types (in the example above, as `int`), they are converted to that type and validated against it. -For example, if `skip` is declared as an `int`, sending a value that cannot be converted to an integer: +For example, if `skip` is declared as an `int`, sending a value that cannot be converted to an integer: ``` http://127.0.0.1:8000/items/?skip=abc ```