Coverage for docs_src / body_multiple_params / tutorial004_an_py310.py: 100%
18 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1from typing import Annotated 1abefcd
3from fastapi import Body, FastAPI 1abefcd
4from pydantic import BaseModel 1abefcd
6app = FastAPI() 1abefcd
9class Item(BaseModel): 1abefcd
10 name: str 1abcd
11 description: str | None = None 1abefcd
12 price: float 1abcd
13 tax: float | None = None 1abefcd
16class User(BaseModel): 1abefcd
17 username: str 1abcd
18 full_name: str | None = None 1abefcd
21@app.put("/items/{item_id}") 1abefcd
22async def update_item( 1abefcd
23 *,
24 item_id: int,
25 item: Item,
26 user: User,
27 importance: Annotated[int, Body(gt=0)],
28 q: str | None = None,
29):
30 results = {"item_id": item_id, "item": item, "user": user, "importance": importance} 1gkhlimjn
31 if q: 1gkhlimjn
32 results.update({"q": q}) 1ghij
33 return results 1gkhlimjn