mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
operation_ids give us better function names when generating the typescript API from the openapi.json. BaseModel.Config.title does the same for type names. Response models (or 204 status codes) need to be explicit or the API will be declared as returning any.
15 lines
399 B
Python
15 lines
399 B
Python
from fastapi import APIRouter, Depends
|
|
|
|
from game import Game
|
|
from game.server import GameContext
|
|
from .models import GameJs
|
|
|
|
router: APIRouter = APIRouter(prefix="/game")
|
|
|
|
|
|
@router.get("/", operation_id="get_game_state", response_model=GameJs)
|
|
def game_state(game: Game | None = Depends(GameContext.get)) -> GameJs | None:
|
|
if game is None:
|
|
return None
|
|
return GameJs.from_game(game)
|