mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Add SwaggerUI
This commit is contained in:
parent
c011fa2ea8
commit
05b7e22808
@ -113,7 +113,9 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using ServiceStack;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||
|
||||
namespace Emby.Server.Implementations
|
||||
@ -663,11 +665,36 @@ namespace Emby.Server.Implementations
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
|
||||
.AddApplicationPart(Assembly.Load("Jellyfin.Api"));
|
||||
services.AddApiVersioning(opt => opt.ReportApiVersions = true);
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" });
|
||||
c.DocInclusionPredicate((docName, apiDesc) =>
|
||||
{
|
||||
if (!apiDesc.TryGetMethodInfo(out var methodInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// A bit of a hack to make Swagger pick the versioned endpoints instead of the legacy emby endpoints
|
||||
return methodInfo.DeclaringType?.BaseType == typeof(ControllerBase) &&
|
||||
apiDesc.RelativePath.Contains("api/v");
|
||||
});
|
||||
});
|
||||
|
||||
// Merge the external ServiceCollection into ASP.NET DI
|
||||
services.TryAdd(serviceCollection);
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseSwagger();
|
||||
|
||||
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
||||
// specifying the Swagger JSON endpoint.
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1");
|
||||
});
|
||||
|
||||
app.UseWebSockets();
|
||||
|
||||
app.UseResponseCompression();
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Emby.Naming\Emby.Naming.csproj" />
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IPNetwork2" Version="2.4.0.126" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.2.0" />
|
||||
@ -37,6 +38,7 @@
|
||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.6.0" />
|
||||
<PackageReference Include="sharpcompress" Version="0.24.0" />
|
||||
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.0.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
namespace Jellyfin.Api.Controllers
|
||||
{
|
||||
[ApiVersion("1")]
|
||||
[Route("[controller]")]
|
||||
public class StartupController : ControllerBase
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
@ -21,7 +20,7 @@ namespace Jellyfin.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("Complete")]
|
||||
public void Post()
|
||||
public void CompleteWizard()
|
||||
{
|
||||
_config.Configuration.IsStartupWizardCompleted = true;
|
||||
_config.SetOptimalValues();
|
||||
@ -71,7 +70,7 @@ namespace Jellyfin.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("User")]
|
||||
public async Task Post([FromForm] StartupUser startupUser)
|
||||
public async Task UpdateUser([FromForm] StartupUser startupUser)
|
||||
{
|
||||
var user = _userManager.Users.First();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user