mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(backend): implemented basic controller layer
This commit is contained in:
23
7project/backend/app/schemas/category.py
Normal file
23
7project/backend/app/schemas/category.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel
|
||||
try:
|
||||
# Pydantic v2
|
||||
from pydantic import ConfigDict # type: ignore
|
||||
_HAS_V2 = True
|
||||
except Exception: # pragma: no cover
|
||||
_HAS_V2 = False
|
||||
|
||||
class CategoryBase(BaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
|
||||
class CategoryCreate(CategoryBase):
|
||||
pass
|
||||
|
||||
class CategoryRead(CategoryBase):
|
||||
id: int
|
||||
if _HAS_V2:
|
||||
model_config = ConfigDict(from_attributes=True) # type: ignore
|
||||
else: # Pydantic v1 fallback
|
||||
class Config: # type: ignore
|
||||
orm_mode = True
|
||||
Reference in New Issue
Block a user