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

12 statements  

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

1from fastapi import FastAPI 1abc

2from pydantic import BaseModel, EmailStr 1abc

3 

4app = FastAPI() 1abc

5 

6 

7class BaseUser(BaseModel): 1abc

8 username: str 1abc

9 email: EmailStr 1abc

10 full_name: str | None = None 1abc

11 

12 

13class UserIn(BaseUser): 1abc

14 password: str 1abc

15 

16 

17@app.post("/user/") 1abc

18async def create_user(user: UserIn) -> BaseUser: 1abc

19 return user 1abc