mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Merge pull request #13764 from JPVenson/bugfix/FixOpenApiFor503
Add OpenAPI spec for #12880
This commit is contained in:
commit
2c0ecd6775
@ -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>();
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user