Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 378 for item_2 (0.03 sec)

  1. docs_src/schema_extra_example/tutorial003_an_py310.py

    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        item_id: int,
        item: Annotated[
            Item,
            Body(
                examples=[
                    {
                        "name": "Foo",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 673 bytes
    - Viewed (0)
  2. docs_src/body/tutorial004_py39.py

    from fastapi import FastAPI
    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
    
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def update_item(item_id: int, item: Item, q: Union[str, None] = None):
        result = {"item_id": item_id, **item.model_dump()}
        if q:
            result.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 458 bytes
    - Viewed (0)
  3. docs_src/body_multiple_params/tutorial003_py310.py

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    class User(BaseModel):
        username: str
        full_name: str | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(item_id: int, item: Item, user: User, importance: int = Body()):
        results = {"item_id": item_id, "item": item, "user": user, "importance": importance}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 504 bytes
    - Viewed (0)
  4. docs_src/body_nested_models/tutorial005_py39.py

        url: HttpUrl
        name: str
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: set[str] = set()
        image: Union[Image, None] = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(item_id: int, item: Item):
        results = {"item_id": item_id, "item": item}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 512 bytes
    - Viewed (0)
  5. docs_src/schema_extra_example/tutorial004_py310.py

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        *,
        item_id: int,
        item: Item = Body(
            examples=[
                {
                    "name": "Foo",
                    "description": "A very nice Item",
                    "price": 35.4,
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Jul 01 16:43:29 UTC 2023
    - 786 bytes
    - Viewed (0)
  6. docs_src/schema_extra_example/tutorial004_an_py310.py

    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        *,
        item_id: int,
        item: Annotated[
            Item,
            Body(
                examples=[
                    {
                        "name": "Foo",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Jul 01 16:43:29 UTC 2023
    - 917 bytes
    - Viewed (0)
  7. docs_src/body_updates/tutorial002_py39.py

    }
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_item(item_id: str):
        return items[item_id]
    
    
    @app.patch("/items/{item_id}", response_model=Item)
    async def update_item(item_id: str, item: Item):
        stored_item_data = items[item_id]
        stored_item_model = Item(**stored_item_data)
        update_data = item.model_dump(exclude_unset=True)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 1K bytes
    - Viewed (0)
  8. docs_src/dependencies/tutorial008b_py39.py

    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: str = Depends(get_username)):
        if item_id not in data:
            raise HTTPException(status_code=404, detail="Item not found")
        item = data[item_id]
        if item["owner"] != username:
            raise OwnerError(username)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 735 bytes
    - Viewed (0)
  9. tests/test_tutorial/test_path_params/test_tutorial001.py

    from docs_src.path_params.tutorial001_py39 import app
    
    client = TestClient(app)
    
    
    @pytest.mark.parametrize(
        ("item_id", "expected_response"),
        [
            (1, {"item_id": "1"}),
            ("alice", {"item_id": "alice"}),
        ],
    )
    def test_get_items(item_id, expected_response):
        response = client.get(f"/items/{item_id}")
        assert response.status_code == 200, response.text
        assert response.json() == expected_response
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 3.9K bytes
    - Viewed (0)
  10. docs_src/schema_extra_example/tutorial005_py310.py

    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        *,
        item_id: int,
        item: Item = Body(
            openapi_examples={
                "normal": {
                    "summary": "A normal example",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Aug 26 18:03:13 UTC 2023
    - 1.3K bytes
    - Viewed (0)
Back to top