This commit is contained in:
32
services/profiles/src/app/schemas/profile.py
Normal file
32
services/profiles/src/app/schemas/profile.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
from typing import List
|
||||
from uuid import UUID
|
||||
|
||||
try:
|
||||
# Pydantic v2
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
_V2 = True
|
||||
except Exception:
|
||||
# Pydantic v1 fallback
|
||||
from pydantic import BaseModel, Field
|
||||
ConfigDict = None
|
||||
_V2 = False
|
||||
|
||||
class ProfileBase(BaseModel):
|
||||
gender: str
|
||||
city: str
|
||||
languages: List[str] = Field(default_factory=list)
|
||||
interests: List[str] = Field(default_factory=list)
|
||||
|
||||
class ProfileCreate(ProfileBase):
|
||||
pass
|
||||
|
||||
class ProfileOut(ProfileBase):
|
||||
id: UUID
|
||||
user_id: UUID
|
||||
|
||||
if _V2:
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
else:
|
||||
class Config:
|
||||
orm_mode = True
|
||||
Reference in New Issue
Block a user