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

13 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from typing import List, Union 1abcdefg

2 

3from fastapi import FastAPI 1abcdefg

4from pydantic import BaseModel 1abcdefg

5 

6 

7class Item(BaseModel): 1abcdefg

8 name: str 1abcdefg

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

10 

11 

12app = FastAPI(separate_input_output_schemas=False) 1abcdefg

13 

14 

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

16def create_item(item: Item): 1abcdefg

17 return item 1hijklmn

18 

19 

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

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

22 return [ 1opqrstu

23 Item( 

24 name="Portal Gun", 

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

26 ), 

27 Item(name="Plumbus"), 

28 ]