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

16 statements  

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

1from typing import Any 1abc

2 

3from fastapi import FastAPI 1abc

4from pydantic import BaseModel, EmailStr 1abc

5 

6app = FastAPI() 1abc

7 

8 

9class UserIn(BaseModel): 1abc

10 username: str 1abc

11 password: str 1abc

12 email: EmailStr 1abc

13 full_name: str | None = None 1abc

14 

15 

16class UserOut(BaseModel): 1abc

17 username: str 1abc

18 email: EmailStr 1abc

19 full_name: str | None = None 1abc

20 

21 

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

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

24 return user 1abc