Files
game-marathon/backend/app/schemas/game.py

41 lines
891 B
Python
Raw Normal View History

2025-12-14 02:38:35 +07:00
from datetime import datetime
from pydantic import BaseModel, Field, HttpUrl
from app.schemas.user import UserPublic
class GameBase(BaseModel):
title: str = Field(..., min_length=1, max_length=100)
download_url: str = Field(..., min_length=1)
genre: str | None = Field(None, max_length=50)
class GameCreate(GameBase):
cover_url: str | None = None
class GameUpdate(BaseModel):
title: str | None = Field(None, min_length=1, max_length=100)
download_url: str | None = None
genre: str | None = None
class GameShort(BaseModel):
id: int
title: str
cover_url: str | None = None
class Config:
from_attributes = True
class GameResponse(GameBase):
id: int
cover_url: str | None = None
added_by: UserPublic | None = None
challenges_count: int = 0
created_at: datetime
class Config:
from_attributes = True