diff options
| author | Niels van Velzen <nielsvanvelzen@users.noreply.github.com> | 2025-03-24 19:14:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-24 19:14:41 +0100 |
| commit | 2c0ecd67759f9be56eeef517024e424cd63ce9c9 (patch) | |
| tree | 84d04cb661e0933cde09f35b023d23f2ab49f0fe /Jellyfin.Server | |
| parent | 86801707066122f7ebc1e17d757b69ab92ab9475 (diff) | |
| parent | daf8eca8ae7010b52538eb7bb32b82075ea0ecdc (diff) | |
Merge pull request #13764 from JPVenson/bugfix/FixOpenApiFor503
Add OpenAPI spec for #12880
Diffstat (limited to 'Jellyfin.Server')
| -rw-r--r-- | Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs | 1 | ||||
| -rw-r--r-- | Jellyfin.Server/Filters/RetryOnTemporarlyUnavailableFilter.cs | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index 597643ed1..1a327e0f9 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<IgnoreEnumSchemaFilter>(); + c.OperationFilter<RetryOnTemporarlyUnavailableFilter>(); c.OperationFilter<SecurityRequirementsOperationFilter>(); c.OperationFilter<FileResponseFilter>(); c.OperationFilter<FileRequestFilter>(); diff --git a/Jellyfin.Server/Filters/RetryOnTemporarlyUnavailableFilter.cs b/Jellyfin.Server/Filters/RetryOnTemporarlyUnavailableFilter.cs new file mode 100644 index 000000000..74470eda0 --- /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<string, OpenApiHeader>() + { + { + "Retry-After", + new() { AllowEmptyValue = true, Required = false, Description = "A hint for when to retry the operation in full seconds." } + }, + { + "Message", + new() { AllowEmptyValue = true, Required = false, Description = "A short plain-text reason why the server is not available." } + } + }, + Content = new Dictionary<string, OpenApiMediaType>() + { + { + "text/html", + new OpenApiMediaType() + } + } + }); + } +} |
