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.
23 lines
634 B
Python
23 lines
634 B
Python
from fastapi import APIRouter, Depends
|
|
|
|
from game import Game
|
|
from game.server import GameContext
|
|
from .models import NavMeshPolyJs
|
|
from ..leaflet import ShapelyUtil
|
|
|
|
router: APIRouter = APIRouter(prefix="/navmesh")
|
|
|
|
|
|
@router.get("/", operation_id="get_navmesh", response_model=list[NavMeshPolyJs])
|
|
def get(
|
|
for_player: bool, game: Game = Depends(GameContext.require)
|
|
) -> list[NavMeshPolyJs]:
|
|
mesh = game.coalition_for(for_player).nav_mesh
|
|
return [
|
|
NavMeshPolyJs(
|
|
poly=ShapelyUtil.poly_to_leaflet(p.poly, game.theater),
|
|
threatened=p.threatened,
|
|
)
|
|
for p in mesh.polys
|
|
]
|