Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 726 for item_a (0.03 sec)

  1. docs_src/response_model/tutorial006_py39.py

        },
    }
    
    
    @app.get(
        "/items/{item_id}/name",
        response_model=Item,
        response_model_include=["name", "description"],
    )
    async def read_item_name(item_id: str):
        return items[item_id]
    
    
    @app.get("/items/{item_id}/public", response_model=Item, response_model_exclude=["tax"])
    async def read_item_public_data(item_id: str):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 848 bytes
    - Viewed (0)
  2. tests/test_tutorial/test_query_params_str_validations/test_tutorial002.py

        response = client.get("/items/")
        assert response.status_code == 200
        assert response.json() == {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
    
    
    def test_query_params_str_validations_q_empty_str(client: TestClient):
        response = client.get("/items/", params={"q": ""})
        assert response.status_code == 200
        assert response.json() == {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 4.9K bytes
    - Viewed (0)
  3. docs_src/additional_status_codes/tutorial001_an_py310.py

    app = FastAPI()
    
    items = {"foo": {"name": "Fighters", "size": 6}, "bar": {"name": "Tenders", "size": 3}}
    
    
    @app.put("/items/{item_id}")
    async def upsert_item(
        item_id: str,
        name: Annotated[str | None, Body()] = None,
        size: Annotated[int | None, Body()] = None,
    ):
        if item_id in items:
            item = items[item_id]
            item["name"] = name
            item["size"] = size
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 686 bytes
    - Viewed (0)
  4. tests/test_tutorial/test_path_params_numeric_validations/test_tutorial004.py

        )
        return TestClient(mod.app)
    
    
    @pytest.mark.parametrize(
        "path,expected_response",
        [
            ("/items/42?q=", {"item_id": 42}),
            ("/items/1?q=somequery", {"item_id": 1, "q": "somequery"}),
        ],
    )
    def test_read_items(client: TestClient, path, expected_response):
        response = client.get(path)
        assert response.status_code == 200, response.text
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 6K bytes
    - Viewed (0)
  5. docs_src/app_testing/tutorial004_py39.py

    from fastapi.testclient import TestClient
    
    items = {}
    
    
    @asynccontextmanager
    async def lifespan(app: FastAPI):
        items["foo"] = {"name": "Fighters"}
        items["bar"] = {"name": "Tenders"}
        yield
        # clean up items
        items.clear()
    
    
    app = FastAPI(lifespan=lifespan)
    
    
    @app.get("/items/{item_id}")
    async def read_items(item_id: str):
        return items[item_id]
    
    
    def test_read_items():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 1.2K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_path_params_numeric_validations/test_tutorial002_tutorial003.py

        )
        return TestClient(mod.app)
    
    
    @pytest.mark.parametrize(
        "path,expected_response",
        [
            ("/items/42?q=", {"item_id": 42}),
            ("/items/123?q=somequery", {"item_id": 123, "q": "somequery"}),
        ],
    )
    def test_read_items(client: TestClient, path, expected_response):
        response = client.get(path)
        assert response.status_code == 200, response.text
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 5.6K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_path_params_numeric_validations/test_tutorial001.py

        )
        return TestClient(mod.app)
    
    
    @pytest.mark.parametrize(
        "path,expected_response",
        [
            ("/items/42", {"item_id": 42}),
            ("/items/123?item-query=somequery", {"item_id": 123, "q": "somequery"}),
        ],
    )
    def test_read_items(client: TestClient, path, expected_response):
        response = client.get(path)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 5.6K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_query_params_str_validations/test_tutorial005.py

        response = client.get("/items/")
        assert response.status_code == 200
        assert response.json() == {
            "items": [{"item_id": "Foo"}, {"item_id": "Bar"}],
            "q": "fixedquery",
        }
    
    
    def test_query_params_str_validations_q_query(client: TestClient):
        response = client.get("/items/", params={"q": "query"})
        assert response.status_code == 200
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 4.3K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_query_params_str_validations/test_tutorial007.py

        response = client.get("/items/")
        assert response.status_code == 200
        assert response.json() == {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
    
    
    def test_query_params_str_validations_q_fixedquery(client: TestClient):
        response = client.get("/items/", params={"q": "fixedquery"})
        assert response.status_code == 200
        assert response.json() == {
            "items": [{"item_id": "Foo"}, {"item_id": "Bar"}],
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 4.6K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_handling_errors/test_tutorial004.py

    client = TestClient(app)
    
    
    def test_get_validation_error():
        response = client.get("/items/foo")
        assert response.status_code == 400, response.text
        assert "Validation errors:" in response.text
        assert "Field: ('path', 'item_id')" in response.text
    
    
    def test_get_http_error():
        response = client.get("/items/3")
        assert response.status_code == 418, response.text
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 3.4K bytes
    - Viewed (0)
Back to top