jellyfin/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs

34 lines
1.2 KiB
C#
Raw Normal View History

2019-11-23 19:43:30 +01:00
using Microsoft.AspNetCore.Builder;
namespace Jellyfin.Server.Extensions
2019-11-23 19:43:30 +01:00
{
2019-11-23 20:31:17 +01:00
/// <summary>
/// Extensions for adding API specific functionality to the application pipeline.
/// </summary>
2019-11-23 19:43:30 +01:00
public static class ApiApplicationBuilderExtensions
{
2019-11-23 20:31:17 +01:00
/// <summary>
/// Adds swagger and swagger UI to the application pipeline.
/// </summary>
/// <param name="applicationBuilder">The application builder.</param>
/// <returns>The updated application builder.</returns>
2019-11-23 19:43:30 +01:00
public static IApplicationBuilder UseJellyfinApiSwagger(this IApplicationBuilder applicationBuilder)
{
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
2020-04-19 18:51:51 +02:00
const string specEndpoint = "/swagger/v1/swagger.json";
return applicationBuilder.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint(specEndpoint, "Jellyfin API V1");
2020-04-19 19:24:03 +02:00
c.RoutePrefix = "api-docs/swagger";
2020-04-19 18:51:51 +02:00
})
.UseReDoc(c =>
{
c.SpecUrl(specEndpoint);
2020-04-19 19:24:03 +02:00
c.RoutePrefix = "api-docs/redoc";
2020-04-19 18:51:51 +02:00
});
2019-11-23 19:43:30 +01:00
}
}
}