feat(backend): add Pydantic schemas
This commit is contained in:
26
backend/src/schemas/category.py
Normal file
26
backend/src/schemas/category.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CategoryBase(BaseModel):
|
||||
"""Base category schema."""
|
||||
|
||||
name: str
|
||||
slug: str
|
||||
description: str | None = None
|
||||
|
||||
|
||||
class CategoryResponse(CategoryBase):
|
||||
"""Category response schema."""
|
||||
|
||||
id: UUID
|
||||
question_count: int = 0
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class CategoryListResponse(BaseModel):
|
||||
"""Response for category list."""
|
||||
|
||||
items: list[CategoryResponse]
|
||||
Reference in New Issue
Block a user