pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
317 B
19 lines
317 B
from fastapi import FastAPI
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class BaseUser(BaseModel):
|
|
username: str
|
|
email: EmailStr
|
|
full_name: str | None = None
|
|
|
|
|
|
class UserIn(BaseUser):
|
|
password: str
|
|
|
|
|
|
@app.post("/user/")
|
|
async def create_user(user: UserIn) -> BaseUser:
|
|
return user
|
|
|