FastAPI Response Model via Pydantic
from pydantic import BaseModel
# Note: This file is used to define Pydantic models
# Used for POST and RESPONSE in FastAPI
# The below code handles the user sending data to us
class PostBase(BaseModel):
title: str
content: str
published: bool = True
class PostCreate(PostBase):
pass
# The below code handles us sending data back to the user
class PostResponse(BaseModel):
title: str
content: str
published: bool
Last updated