feat(api): optional refresh param on GET /api/graphics-elements
Review SHOULD-FIX (#145): the SPA graphics picker could go stale because Blazor ran RefreshGraphicsElements (disk->DB sync) before listing, while the API endpoint never refreshed — a newly added .yml would not appear. GET /api/graphics-elements?refresh=true now sends RefreshGraphicsElements before the list query; default false leaves existing callers untouched. The playback troubleshooting screen passes refresh=true. Controller tests cover refresh-iff-true ordering; regenerated OpenAPI v1.json (endpoint index and generated TS schemas unchanged - query params are not part of either). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,8 +12,20 @@ public class GraphicsElementController(IMediator mediator) : ControllerBase
|
||||
[HttpGet("/api/graphics-elements", Name = "GetGraphicsElements")]
|
||||
[Tags("Graphics Elements")]
|
||||
[EndpointSummary("Get all graphics elements")]
|
||||
[EndpointDescription(
|
||||
"Returns all graphics elements. Pass refresh=true to first re-sync the on-disk graphics element " +
|
||||
"definitions into the database (matching the legacy Blazor behavior) so newly added files appear.")]
|
||||
[EndpointGroupName("general")]
|
||||
[ProducesResponseType(typeof(List<GraphicsElementResponseModel>), StatusCodes.Status200OK)]
|
||||
public async Task<List<GraphicsElementResponseModel>> GetAll(CancellationToken cancellationToken) =>
|
||||
await mediator.Send(new GetAllGraphicsElementsForApi(), cancellationToken);
|
||||
public async Task<List<GraphicsElementResponseModel>> GetAll(
|
||||
[FromQuery] bool refresh,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (refresh)
|
||||
{
|
||||
await mediator.Send(new RefreshGraphicsElements(), cancellationToken);
|
||||
}
|
||||
|
||||
return await mediator.Send(new GetAllGraphicsElementsForApi(), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4874,7 +4874,17 @@
|
||||
"Graphics Elements"
|
||||
],
|
||||
"summary": "Get all graphics elements",
|
||||
"description": "Returns all graphics elements. Pass refresh=true to first re-sync the on-disk graphics element definitions into the database (matching the legacy Blazor behavior) so newly added files appear.",
|
||||
"operationId": "GetGraphicsElements",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "refresh",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
|
||||
Reference in New Issue
Block a user