Create requests/responses models from OpenAPI JSON file
This commit is contained in:
0
models/__init__.py
Normal file
0
models/__init__.py
Normal file
15
models/errors.py
Normal file
15
models/errors.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ValidationError:
|
||||||
|
"""Model for validation errors."""
|
||||||
|
loc: list
|
||||||
|
msg: str
|
||||||
|
type: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class HTTPValidationError:
|
||||||
|
"""Model for HTTP validation errors."""
|
||||||
|
detail: list[ValidationError] = field(default_factory=list)
|
17
models/requests.py
Normal file
17
models/requests.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Literal
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GameStartRequest:
|
||||||
|
"""Request model for starting a new game."""
|
||||||
|
player_name: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GameDecisionRequest:
|
||||||
|
"""Request model for making a game decision."""
|
||||||
|
decision: Literal["Accept", "Reject"]
|
||||||
|
session_id: UUID
|
||||||
|
client_id: UUID
|
23
models/responses.py
Normal file
23
models/responses.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Dict, Optional, Any
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GameStartResponse:
|
||||||
|
"""Response model for a new game started."""
|
||||||
|
message: str
|
||||||
|
session_id: UUID
|
||||||
|
player_id: str
|
||||||
|
client_id: UUID
|
||||||
|
client_data: Dict[str, Any]
|
||||||
|
score: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GameDecisionResponse:
|
||||||
|
"""Response model for a game decision result."""
|
||||||
|
status: str
|
||||||
|
score: int
|
||||||
|
client_id: Optional[UUID] = None
|
||||||
|
client_data: Optional[Dict[str, Any]] = None
|
Reference in New Issue
Block a user