add existing api endpoints to scalar docs (#2374)
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
[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,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))
|
||||
|
||||
@@ -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
|
||||
.InformationalVersion ?? "unknown";
|
||||
|
||||
[HttpGet("/api/version")]
|
||||
[Tags("Version")]
|
||||
[EndpointSummary("Get version")]
|
||||
public string GetVersion() => Version;
|
||||
}
|
||||
|
||||
+6
-4
@@ -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
|
||||
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";
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user