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.
24 lines
711 B
Python
24 lines
711 B
Python
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from game import Game
|
|
from .models import FrontLineJs
|
|
from ..dependencies import GameContext
|
|
|
|
router: APIRouter = APIRouter(prefix="/front-lines")
|
|
|
|
|
|
@router.get("/", operation_id="list_front_lines", response_model=list[FrontLineJs])
|
|
def list_front_lines(game: Game = Depends(GameContext.require)) -> list[FrontLineJs]:
|
|
return FrontLineJs.all_in_game(game)
|
|
|
|
|
|
@router.get(
|
|
"/{front_line_id}", operation_id="get_front_line_by_id", response_model=FrontLineJs
|
|
)
|
|
def get_front_line(
|
|
front_line_id: UUID, game: Game = Depends(GameContext.require)
|
|
) -> FrontLineJs:
|
|
return FrontLineJs.for_front_line(game.db.front_lines.get(front_line_id))
|