Coverage for docs_src / body / tutorial002_py310.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi import FastAPI 1abc
2from pydantic import BaseModel 1abc
5class Item(BaseModel): 1abc
6 name: str 1abc
7 description: str | None = None 1abc
8 price: float 1abc
9 tax: float | None = None 1abc
12app = FastAPI() 1abc
15@app.post("/items/") 1abc
16async def create_item(item: Item): 1abc
17 item_dict = item.model_dump() 1dgehfi
18 if item.tax is not None: 1dgehfi
19 price_with_tax = item.price + item.tax 1def
20 item_dict.update({"price_with_tax": price_with_tax}) 1def
21 return item_dict 1dgehfi