Debian Codegraph @

docs_src/response_model/tutorial002_py310.py

raw
1 from fastapi import FastAPI
2 from pydantic import BaseModel, EmailStr
3
4 app = FastAPI()
5
6
7 class UserIn(BaseModel):
8 username: str
9 password: str
10 email: EmailStr
11 full_name: str | None = None
12
13
14 # Don't do this in production!
15 @app.post("/user/")
16 async def create_user(user: UserIn) -> UserIn:
17 return user