Coverage for docs_src/separate_openapi_schemas/tutorial002_py39.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from typing import Optional 1abcd

2 

3from fastapi import FastAPI 1abcd

4from pydantic import BaseModel 1abcd

5 

6 

7class Item(BaseModel): 1abcd

8 name: str 1abcd

9 description: Optional[str] = None 1abcd

10 

11 

12app = FastAPI(separate_input_output_schemas=False) 1abcd

13 

14 

15@app.post("/items/") 1abcd

16def create_item(item: Item): 1abcd

17 return item 1abcd

18 

19 

20@app.get("/items/") 1abcd

21def read_items() -> list[Item]: 1abcd

22 return [ 1abcd

23 Item( 

24 name="Portal Gun", 

25 description="Device to travel through the multi-rick-verse", 

26 ), 

27 Item(name="Plumbus"), 

28 ]