Files
mtgonline/backend/app/schemas/mtg_card_schemas.py
T
akadmin 1df04aea52 Phase 7: End-to-End API Testing - Database setup, migrations, and application fixes
- Switched from psycopg2 to asyncpg for async SQLAlchemy support
- Fixed router registration in main.py - removed duplicate prefixes
- Added user_data export to routers/__init__.py
- Refactored decks router to use DeckManager service layer
- Integrated FuzzyCardMatcher into card_router search endpoints
- Made WishlistCreate.card_id optional for proper schema validation
- Set PostgreSQL password and configured scram-sha-256 auth
- Updated alembic.ini to use local PostgreSQL instead of Docker hostname
- Created generic_schemas.py for reusable schema patterns
- Added test_routers.py and test_schema_validation.py test files
- All 6 Alembic migrations applied successfully (37 tables created)
- Application running on port 8000 with all services connected
2026-08-18 03:35:19 +00:00

117 lines
2.7 KiB
Python

"""Pydantic schemas for MTG card data."""
from pydantic import BaseModel, ConfigDict
from typing import Optional, List
from datetime import datetime
class MtgCardResponse(BaseModel):
"""MTG card response."""
id: int
source_id: Optional[int]
name: str
mana_cost: Optional[str]
type_line: Optional[str]
oracle_text: Optional[str]
power: Optional[str]
toughness: Optional[str]
rarity: Optional[str]
layout: Optional[str]
artist: Optional[str]
flavor_text: Optional[str]
numbers: Optional[str]
identifiers: Optional[str]
images: Optional[str]
image: Optional[str]
card_parts: Optional[str]
keywords: Optional[str]
legalities: Optional[str]
set_code: Optional[str]
set_name: Optional[str]
synced_at: Optional[datetime]
created_at: datetime
model_config = ConfigDict(from_attributes=True)
class MtgCardSearchRequest(BaseModel):
"""MTG card search request."""
query: str
limit: int = 50
offset: int = 0
class MtgCardSearchResponse(BaseModel):
"""MTG card search response."""
cards: List[MtgCardResponse]
total: int
page: int
page_size: int
total_pages: int
class MtgSetResponse(BaseModel):
"""MTG set response."""
id: int
name: str
code: str
release_date: Optional[datetime]
card_count: Optional[int]
model_config = ConfigDict(from_attributes=True)
class MtgCardMirrorResponse(BaseModel):
"""Mirrored card data response."""
id: int
source_id: Optional[int]
name: str
mana_cost: Optional[str]
type_line: Optional[str]
oracle_text: Optional[str]
power: Optional[str]
toughness: Optional[str]
rarity: Optional[str]
layout: Optional[str]
artist: Optional[str]
flavor_text: Optional[str]
numbers: Optional[str]
identifiers: Optional[str]
images: Optional[str]
image: Optional[str]
card_parts: Optional[str]
keywords: Optional[str]
legalities: Optional[str]
set_code: Optional[str]
set_name: Optional[str]
synced_at: Optional[datetime]
created_at: datetime
model_config = ConfigDict(from_attributes=True)
class DeckCardLinkResponse(BaseModel):
"""Deck-card link response."""
id: int
deck_id: int
card_id: int
quantity: int
zone: str
card: MtgCardMirrorResponse
model_config = ConfigDict(from_attributes=True)
class DeckWithCardsResponse(BaseModel):
"""Deck response with card links."""
id: int
name: str
content: str
format: str
status: str
folder_id: Optional[int]
owner_id: int
creation_date: datetime
card_links: List[DeckCardLinkResponse] = []
model_config = ConfigDict(from_attributes=True)