Browse Source

add existing api endpoints to scalar docs (#2374)

pull/2375/head
Jason Dove 11 months ago committed by GitHub
parent
commit
73b8d68a09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      ErsatzTV/Controllers/Api/ChannelController.cs
  2. 7
      ErsatzTV/Controllers/Api/LibrariesController.cs
  3. 5
      ErsatzTV/Controllers/Api/MaintenanceController.cs
  4. 5
      ErsatzTV/Controllers/Api/SessionController.cs
  5. 3
      ErsatzTV/Controllers/Api/VersionController.cs
  6. 10
      ErsatzTV/Startup.cs

3
ErsatzTV/Controllers/Api/ChannelController.cs

@ -18,6 +18,9 @@ public class ChannelController(ChannelWriter<IBackgroundServiceRequest> workerCh @@ -18,6 +18,9 @@ public class ChannelController(ChannelWriter<IBackgroundServiceRequest> workerCh
public async Task<List<ChannelResponseModel>> GetAll() => await mediator.Send(new GetAllChannelsForApi());
[HttpPost("/api/channels/{channelNumber}/playout/reset")]
[Tags("Channels")]
[EndpointSummary("Reset channel playout")]
[EndpointGroupName("general")]
public async Task<IActionResult> ResetPlayout(string channelNumber)
{
Option<int> maybePlayoutId = await mediator.Send(new GetPlayoutIdByChannelNumber(channelNumber));

7
ErsatzTV/Controllers/Api/LibrariesController.cs

@ -6,15 +6,20 @@ using Microsoft.AspNetCore.Mvc; @@ -6,15 +6,20 @@ using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api;
[ApiController]
[EndpointGroupName("general")]
public class LibrariesController(ITelevisionRepository televisionRepository, IMediator mediator)
{
[HttpPost("/api/libraries/{id:int}/scan")]
public async Task<IActionResult> ResetPlayout(int id) =>
[Tags("Libraries")]
[EndpointSummary("Scan library")]
public async Task<IActionResult> ScanLibrary(int id) =>
await mediator.Send(new QueueLibraryScanByLibraryId(id))
? new OkResult()
: new NotFoundResult();
[HttpPost("/api/libraries/{id:int}/scan-show")]
[Tags("Libraries")]
[EndpointSummary("Scan show")]
public async Task<IActionResult> ScanShow(int id, [FromBody] ScanShowRequest request)
{
if (string.IsNullOrWhiteSpace(request.ShowTitle))

5
ErsatzTV/Controllers/Api/MaintenanceController.cs

@ -6,9 +6,12 @@ using Microsoft.AspNetCore.Mvc; @@ -6,9 +6,12 @@ using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api;
[ApiController]
[EndpointGroupName("general")]
public class MaintenanceController(IMediator mediator)
{
[HttpGet("/api/maintenance/gc")]
[Tags("Maintenance")]
[EndpointSummary("Garbage collect")]
public async Task<IActionResult> GarbageCollection([FromQuery] bool force = false)
{
await mediator.Send(new ReleaseMemory(force));
@ -16,6 +19,8 @@ public class MaintenanceController(IMediator mediator) @@ -16,6 +19,8 @@ public class MaintenanceController(IMediator mediator)
}
[HttpPost("/api/maintenance/empty_trash")]
[Tags("Maintenance")]
[EndpointSummary("Empty trash")]
public async Task<IActionResult> EmptyTrash()
{
Either<BaseError, Unit> result = await mediator.Send(new EmptyTrash());

5
ErsatzTV/Controllers/Api/SessionController.cs

@ -5,12 +5,17 @@ using Microsoft.AspNetCore.Mvc; @@ -5,12 +5,17 @@ using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api;
[ApiController]
[EndpointGroupName("general")]
public class SessionController(IFFmpegSegmenterService ffmpegSegmenterService)
{
[HttpGet("api/sessions")]
[Tags("Sessions")]
[EndpointSummary("Get sessions")]
public List<HlsSessionModel> GetSessions() => ffmpegSegmenterService.Workers.Map(w => w.GetModel()).ToList();
[HttpDelete("api/session/{channelNumber}")]
[Tags("Sessions")]
[EndpointSummary("Stop session")]
public async Task<IActionResult> StopSession(string channelNumber, CancellationToken cancellationToken)
{
if (await ffmpegSegmenterService.StopChannel(channelNumber, cancellationToken))

3
ErsatzTV/Controllers/Api/VersionController.cs

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api;
[ApiController]
[EndpointGroupName("general")]
public class VersionController
{
private static readonly string Version;
@ -14,5 +15,7 @@ public class VersionController @@ -14,5 +15,7 @@ public class VersionController
.InformationalVersion ?? "unknown";
[HttpGet("/api/version")]
[Tags("Version")]
[EndpointSummary("Get version")]
public string GetVersion() => Version;
}

10
ErsatzTV/Startup.cs

@ -145,10 +145,11 @@ public class Startup @@ -145,10 +145,11 @@ public class Startup
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(FileSystemLayout.DataProtectionFolder));
services.AddOpenApi("scripted-schedule", options =>
{
options.ShouldInclude += a => a.GroupName == "scripted-schedule";
});
services.AddOpenApi("v1", options => { options.ShouldInclude += a => a.GroupName == "general"; });
services.AddOpenApi(
"scripted-schedule",
options => { options.ShouldInclude += a => a.GroupName == "scripted-schedule"; });
OidcHelper.Init(Configuration);
JwtHelper.Init(Configuration);
@ -602,6 +603,7 @@ public class Startup @@ -602,6 +603,7 @@ public class Startup
endpoints.MapScalarApiReference("/docs", options =>
{
options.AddDocument("scripted-schedule", "Scripted Schedule", "openapi/scripted-schedule.json");
options.AddDocument("v1", "General", "openapi/v1.json");
options.HideClientButton = true;
options.Title = "ErsatzTV API Reference";
});

Loading…
Cancel
Save