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

13 statements  

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

1from typing import List, Union 1abcde

2 

3from fastapi import FastAPI 1abcde

4from pydantic import BaseModel 1abcde

5 

6 

7class Item(BaseModel): 1abcde

8 name: str 1abcde

9 description: Union[str, None] = None 1abcde

10 

11 

12app = FastAPI() 1abcde

13 

14 

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

16def create_item(item: Item): 1abcde

17 return item 1abcde

18 

19 

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

21def read_items() -> List[Item]: 1abcde

22 return [ 1abcde

23 Item( 

24 name="Portal Gun", 

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

26 ), 

27 Item(name="Plumbus"), 

28 ]