diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index 597643ed19..1a327e0f9f 100644 --- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs @@ -247,6 +247,7 @@ namespace Jellyfin.Server.Extensions c.AddSwaggerTypeMappings(); c.SchemaFilter(); + c.OperationFilter(); c.OperationFilter(); c.OperationFilter(); c.OperationFilter(); diff --git a/Jellyfin.Server/Filters/RetryOnTemporarlyUnavailableFilter.cs b/Jellyfin.Server/Filters/RetryOnTemporarlyUnavailableFilter.cs new file mode 100644 index 0000000000..bd572df9b7 --- /dev/null +++ b/Jellyfin.Server/Filters/RetryOnTemporarlyUnavailableFilter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Net.Http.Headers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Jellyfin.Server.Filters; + +internal class RetryOnTemporarlyUnavailableFilter : IOperationFilter +{ + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + operation.Responses.Add("503", new OpenApiResponse() + { + Description = "The server is currently starting or is temporarly not available.", + Headers = new Dictionary() + { + { + "retry-after", + new() { AllowEmptyValue = true, Required = false, Description = "A hint for when to retry the operation." } + }, + { + "message", + new() { AllowEmptyValue = true, Required = false, Description = "A short plain-text reason why the server is not available." } + } + }, + Content = new Dictionary() + { + { + "text/html", + new OpenApiMediaType() + } + } + }); + } +}