Automated Action 06df0285b1 Implement Blogging Platform API with FastAPI and SQLite
- Set up project structure and dependencies
- Create database models for users, posts, comments, and tags
- Set up Alembic for database migrations
- Implement user authentication (register, login)
- Create CRUD endpoints for blog posts, comments, and tags
- Add health check endpoint
- Set up proper error handling
- Update README with project details and setup instructions
2025-06-02 21:58:50 +00:00

50 lines
978 B
Python

from datetime import datetime
from typing import Optional, List
from pydantic import BaseModel
from app.schemas.user import User
from app.schemas.tag import Tag
# Shared properties
class PostBase(BaseModel):
title: Optional[str] = None
content: Optional[str] = None
published: Optional[bool] = True
# Properties to receive via API on creation
class PostCreate(PostBase):
title: str
content: str
tag_ids: Optional[List[int]] = []
# Properties to receive via API on update
class PostUpdate(PostBase):
tag_ids: Optional[List[int]] = None
# Properties shared by models stored in DB
class PostInDBBase(PostBase):
id: int
title: str
content: str
author_id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
# Properties to return to client
class Post(PostInDBBase):
author: User
tags: List[Tag] = []
# Properties stored in DB
class PostInDB(PostInDBBase):
pass