42 lines
987 B
Python
42 lines
987 B
Python
|
|
"""Pydantic schemas for Label model"""
|
||
|
|
from typing import Optional
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict, Field
|
||
|
|
|
||
|
|
|
||
|
|
class LabelCreateRequest(BaseModel):
|
||
|
|
"""Schema for creating a new label"""
|
||
|
|
|
||
|
|
model_config = ConfigDict(
|
||
|
|
json_schema_extra={
|
||
|
|
"example": {
|
||
|
|
"name": "High Priority",
|
||
|
|
"color": "#ff0000",
|
||
|
|
}
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
name: str = Field(..., min_length=1, max_length=100, description="Label name")
|
||
|
|
color: Optional[str] = Field(None, max_length=7, description="Label color (hex)")
|
||
|
|
|
||
|
|
|
||
|
|
class LabelResponse(BaseModel):
|
||
|
|
"""Schema for label response"""
|
||
|
|
|
||
|
|
model_config = ConfigDict(
|
||
|
|
from_attributes=True,
|
||
|
|
json_schema_extra={
|
||
|
|
"example": {
|
||
|
|
"id": 1,
|
||
|
|
"name": "High Priority",
|
||
|
|
"color": "#ff0000",
|
||
|
|
"board_id": 1,
|
||
|
|
}
|
||
|
|
},
|
||
|
|
)
|
||
|
|
|
||
|
|
id: int
|
||
|
|
name: str
|
||
|
|
color: Optional[str] = None
|
||
|
|
board_id: int
|