53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
|
|
"""Pydantic schemas for CheckItem model"""
|
||
|
|
from datetime import datetime
|
||
|
|
from typing import Optional
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict, Field
|
||
|
|
|
||
|
|
|
||
|
|
class CheckItemCreateRequest(BaseModel):
|
||
|
|
"""Schema for creating a new check item"""
|
||
|
|
|
||
|
|
model_config = ConfigDict(
|
||
|
|
json_schema_extra={
|
||
|
|
"example": {
|
||
|
|
"name": "First step",
|
||
|
|
"pos": 0,
|
||
|
|
"state": "incomplete",
|
||
|
|
"due": "2024-12-31T23:59:59",
|
||
|
|
}
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
name: str = Field(..., min_length=1, max_length=200, description="Check item name")
|
||
|
|
pos: int = Field(default=0, description="Check item position")
|
||
|
|
state: str = Field(
|
||
|
|
default="incomplete", description="State: complete or incomplete"
|
||
|
|
)
|
||
|
|
due: Optional[datetime] = Field(None, description="Due date")
|
||
|
|
|
||
|
|
|
||
|
|
class CheckItemResponse(BaseModel):
|
||
|
|
"""Schema for check item response"""
|
||
|
|
|
||
|
|
model_config = ConfigDict(
|
||
|
|
from_attributes=True,
|
||
|
|
json_schema_extra={
|
||
|
|
"example": {
|
||
|
|
"id": 1,
|
||
|
|
"name": "First step",
|
||
|
|
"pos": 0,
|
||
|
|
"state": "incomplete",
|
||
|
|
"due": "2024-12-31T23:59:59",
|
||
|
|
"checklist_id": 1,
|
||
|
|
}
|
||
|
|
},
|
||
|
|
)
|
||
|
|
|
||
|
|
id: int
|
||
|
|
name: str
|
||
|
|
pos: int
|
||
|
|
state: str
|
||
|
|
due: Optional[datetime] = None
|
||
|
|
checklist_id: int
|