mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-08 23:00:51 +02:00
Fix documentation endpoint for use with baseUrl
This commit is contained in:
parent
3ab61dbdc2
commit
2542a27bd5
|
@ -1,3 +1,4 @@
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Extensions
|
namespace Jellyfin.Server.Extensions
|
||||||
|
@ -11,23 +12,36 @@ namespace Jellyfin.Server.Extensions
|
||||||
/// Adds swagger and swagger UI to the application pipeline.
|
/// Adds swagger and swagger UI to the application pipeline.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="applicationBuilder">The application builder.</param>
|
/// <param name="applicationBuilder">The application builder.</param>
|
||||||
|
/// <param name="serverConfigurationManager">The server configuration.</param>
|
||||||
/// <returns>The updated application builder.</returns>
|
/// <returns>The updated application builder.</returns>
|
||||||
public static IApplicationBuilder UseJellyfinApiSwagger(this IApplicationBuilder applicationBuilder)
|
public static IApplicationBuilder UseJellyfinApiSwagger(
|
||||||
|
this IApplicationBuilder applicationBuilder,
|
||||||
|
IServerConfigurationManager serverConfigurationManager)
|
||||||
{
|
{
|
||||||
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
||||||
// specifying the Swagger JSON endpoint.
|
// specifying the Swagger JSON endpoint.
|
||||||
const string specEndpoint = "/swagger/v1/swagger.json";
|
|
||||||
|
var baseUrl = serverConfigurationManager.Configuration.BaseUrl.Trim('/');
|
||||||
|
if (!string.IsNullOrEmpty(baseUrl))
|
||||||
|
{
|
||||||
|
baseUrl += '/';
|
||||||
|
}
|
||||||
|
|
||||||
return applicationBuilder
|
return applicationBuilder
|
||||||
.UseSwagger()
|
.UseSwagger(c =>
|
||||||
|
{
|
||||||
|
c.RouteTemplate = $"/{baseUrl}api-docs/{{documentName}}/openapi.json";
|
||||||
|
})
|
||||||
.UseSwaggerUI(c =>
|
.UseSwaggerUI(c =>
|
||||||
{
|
{
|
||||||
c.SwaggerEndpoint(specEndpoint, "Jellyfin API V1");
|
c.SwaggerEndpoint($"/{baseUrl}api-docs/v1/openapi.json", "Jellyfin API v1");
|
||||||
c.RoutePrefix = "api-docs/swagger";
|
c.RoutePrefix = $"{baseUrl}api-docs/v1/swagger";
|
||||||
})
|
})
|
||||||
.UseReDoc(c =>
|
.UseReDoc(c =>
|
||||||
{
|
{
|
||||||
c.SpecUrl(specEndpoint);
|
c.DocumentTitle = "Jellyfin API v1";
|
||||||
c.RoutePrefix = "api-docs/redoc";
|
c.SpecUrl($"/{baseUrl}api-docs/v1/openapi.json");
|
||||||
|
c.RoutePrefix = $"{baseUrl}api-docs/v1/redoc";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace Jellyfin.Server
|
||||||
app.Use(serverApplicationHost.ExecuteWebsocketHandlerAsync);
|
app.Use(serverApplicationHost.ExecuteWebsocketHandlerAsync);
|
||||||
|
|
||||||
// TODO use when old API is removed: app.UseAuthentication();
|
// TODO use when old API is removed: app.UseAuthentication();
|
||||||
app.UseJellyfinApiSwagger();
|
app.UseJellyfinApiSwagger(_serverConfigurationManager);
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
|
|
Loading…
Reference in a new issue