44 lines
1 KiB
Python
44 lines
1 KiB
Python
"""Pydantic schemas for Comment model"""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class CommentCreateRequest(BaseModel):
|
|
"""Schema for creating a new comment"""
|
|
|
|
model_config = ConfigDict(
|
|
json_schema_extra={
|
|
"example": {
|
|
"text": "This is a comment",
|
|
}
|
|
}
|
|
)
|
|
|
|
text: str = Field(..., min_length=1, description="Comment text")
|
|
|
|
|
|
class CommentResponse(BaseModel):
|
|
"""Schema for comment response"""
|
|
|
|
model_config = ConfigDict(
|
|
from_attributes=True,
|
|
json_schema_extra={
|
|
"example": {
|
|
"id": 1,
|
|
"text": "This is a comment",
|
|
"card_id": 1,
|
|
"user_id": 1,
|
|
"created_at": "2024-01-15T10:30:00",
|
|
"updated_at": "2024-01-15T10:30:00",
|
|
}
|
|
},
|
|
)
|
|
|
|
id: int
|
|
text: str
|
|
card_id: int
|
|
user_id: int
|
|
created_at: Optional[datetime] = None
|
|
updated_at: Optional[datetime] = None
|