
- Update Pydantic models to use model_config instead of Config class for v2 compatibility - Fix CORS settings to allow all origins in development mode - Fix circular imports in auth.py - Remove unused imports
34 lines
644 B
Python
34 lines
644 B
Python
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class CategoryBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class CategoryCreate(CategoryBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class CategoryUpdate(CategoryBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
class CategoryInDBBase(CategoryBase):
|
|
id: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {
|
|
"from_attributes": True
|
|
}
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Category(CategoryInDBBase):
|
|
pass |