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

13 statements  

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

1from typing import Union 1abcde

2 

3from fastapi import FastAPI 1abcde

4from pydantic import BaseModel, EmailStr 1abcde

5 

6app = FastAPI() 1abcde

7 

8 

9class BaseUser(BaseModel): 1abcde

10 username: str 1abcde

11 email: EmailStr 1abcde

12 full_name: Union[str, None] = None 1abcde

13 

14 

15class UserIn(BaseUser): 1abcde

16 password: str 1abcde

17 

18 

19@app.post("/user/") 1abcde

20async def create_user(user: UserIn) -> BaseUser: 1abcde

21 return user 1abcde