| | 1 | | using System.Collections.Generic; |
| | 2 | | using Microsoft.OpenApi.Models; |
| | 3 | | using Swashbuckle.AspNetCore.SwaggerGen; |
| | 4 | |
|
| | 5 | | namespace Jellyfin.Server.Filters; |
| | 6 | |
|
| | 7 | | internal class RetryOnTemporarilyUnavailableFilter : IOperationFilter |
| | 8 | | { |
| | 9 | | public void Apply(OpenApiOperation operation, OperationFilterContext context) |
| | 10 | | { |
| 388 | 11 | | operation.Responses.Add( |
| 388 | 12 | | "503", |
| 388 | 13 | | new OpenApiResponse |
| 388 | 14 | | { |
| 388 | 15 | | Description = "The server is currently starting or is temporarily not available.", |
| 388 | 16 | | Headers = new Dictionary<string, OpenApiHeader> |
| 388 | 17 | | { |
| 388 | 18 | | { |
| 388 | 19 | | "Retry-After", new OpenApiHeader |
| 388 | 20 | | { |
| 388 | 21 | | AllowEmptyValue = true, |
| 388 | 22 | | Required = false, |
| 388 | 23 | | Description = "A hint for when to retry the operation in full seconds.", |
| 388 | 24 | | Schema = new OpenApiSchema |
| 388 | 25 | | { |
| 388 | 26 | | Type = "integer", |
| 388 | 27 | | Format = "int32" |
| 388 | 28 | | } |
| 388 | 29 | | } |
| 388 | 30 | | }, |
| 388 | 31 | | { |
| 388 | 32 | | "Message", new OpenApiHeader |
| 388 | 33 | | { |
| 388 | 34 | | AllowEmptyValue = true, |
| 388 | 35 | | Required = false, |
| 388 | 36 | | Description = "A short plain-text reason why the server is not available.", |
| 388 | 37 | | Schema = new OpenApiSchema |
| 388 | 38 | | { |
| 388 | 39 | | Type = "string", |
| 388 | 40 | | Format = "text" |
| 388 | 41 | | } |
| 388 | 42 | | } |
| 388 | 43 | | } |
| 388 | 44 | | }, |
| 388 | 45 | | Content = new Dictionary<string, OpenApiMediaType>() |
| 388 | 46 | | { |
| 388 | 47 | | { "text/html", new OpenApiMediaType() } |
| 388 | 48 | | } |
| 388 | 49 | | }); |
| 388 | 50 | | } |
| | 51 | | } |