Coverage for docs_src/response_model/tutorial003_py310.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from typing import Any 1abcd

2 

3from fastapi import FastAPI 1abcd

4from pydantic import BaseModel, EmailStr 1abcd

5 

6app = FastAPI() 1abcd

7 

8 

9class UserIn(BaseModel): 1abcd

10 username: str 1abcd

11 password: str 1abcd

12 email: EmailStr 1abcd

13 full_name: str | None = None 1abcd

14 

15 

16class UserOut(BaseModel): 1abcd

17 username: str 1abcd

18 email: EmailStr 1abcd

19 full_name: str | None = None 1abcd

20 

21 

22@app.post("/user/", response_model=UserOut) 1abcd

23async def create_user(user: UserIn) -> Any: 1abcd

24 return user 1efgh