api endpoints fix and inclusion
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-08-10 15:39:48 +09:00
parent 7ecc556c77
commit b595bcc9bc
65 changed files with 6046 additions and 263 deletions

View File

@@ -1,32 +1,77 @@
# from pydantic import BaseModel, Field, HttpUrl
# from typing import Optional, List, Literal
# from uuid import UUID
# class ProfileCreate(BaseModel):
# gender: Literal["male", "female", "other"]
# city: str
# languages: List[str] = []
# interests: List[str] = []
# class ProfileUpdate(BaseModel):
# gender: Optional[Literal["male", "female", "other"]] = None
# city: Optional[str] = None
# languages: Optional[List[str]] = None
# interests: Optional[List[str]] = None
# photo_url: Optional[Optional[str]] = Field(default=None)
# class ProfileOut(BaseModel):
# id: UUID
# user_id: UUID
# gender: Literal["male", "female", "other"]
# city: str
# languages: List[str] = []
# interests: List[str] = []
# photo_url: Optional[str] = None
# from pydantic import ConfigDict
# model_config = ConfigDict(from_attributes=True)
# class LikesList(BaseModel):
# items: List[str]
# services/profiles/src/app/schemas/profile.py
from __future__ import annotations
from typing import List, Optional
from uuid import UUID
from typing import List
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
from pydantic import BaseModel, ConfigDict
# Базовые поля профиля
class ProfileBase(BaseModel):
gender: str
city: str
languages: List[str] = Field(default_factory=list)
interests: List[str] = Field(default_factory=list)
languages: List[str]
interests: List[str]
# Для POST /profiles/v1/profiles
class ProfileCreate(ProfileBase):
pass
# Для PATCH /profiles/v1/profiles/me (все поля опциональные)
class ProfileUpdate(BaseModel):
gender: Optional[str] = None
city: Optional[str] = None
languages: Optional[List[str]] = None
interests: Optional[List[str]] = None
photo_url: Optional[str] = None # nullable
# Для ответов
class ProfileOut(ProfileBase):
id: UUID
user_id: UUID
photo_url: Optional[str] = None
if _V2:
model_config = ConfigDict(from_attributes=True)
else:
class Config:
orm_mode = True
# Важно: для возврата ORM-объектов
model_config = ConfigDict(from_attributes=True)
# Для лайков
class LikesList(BaseModel):
items: List[UUID]