Coverage for docs_src/path_operation_configuration/tutorial005_py39.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from typing import Union 1abcd
3from fastapi import FastAPI 1abcd
4from pydantic import BaseModel 1abcd
6app = FastAPI() 1abcd
9class Item(BaseModel): 1abcd
10 name: str 1abcd
11 description: Union[str, None] = None 1abcd
12 price: float 1abcd
13 tax: Union[float, None] = None 1abcd
14 tags: set[str] = set() 1abcd
17@app.post( 1abcd
18 "/items/",
19 response_model=Item,
20 summary="Create an item",
21 response_description="The created item",
22)
23async def create_item(item: Item): 1abcd
24 """
25 Create an item with all the information:
27 - **name**: each item must have a name
28 - **description**: a long description
29 - **price**: required
30 - **tax**: if the item doesn't have tax, you can omit this
31 - **tags**: a set of unique tag strings for this item
32 """
33 return item 1abcd