mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-07 10:14:13 -04:00
Swagger: Creating the swagger page
This commit is contained in:
parent
09ff2e795d
commit
ba37a7cb9b
@ -283,7 +283,7 @@ namespace Kyoo.Core
|
|||||||
builder.ReadFrom.Services(services);
|
builder.ReadFrom.Services(services);
|
||||||
|
|
||||||
const string template =
|
const string template =
|
||||||
"[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} "
|
"[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 25} "
|
||||||
+ "({@i:D10})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}";
|
+ "({@i:D10})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}";
|
||||||
|
|
||||||
if (SystemdHelpers.IsSystemdService())
|
if (SystemdHelpers.IsSystemdService())
|
||||||
|
@ -27,6 +27,8 @@ using Microsoft.Extensions.Options;
|
|||||||
|
|
||||||
// We use threads so tasks are not always awaited.
|
// We use threads so tasks are not always awaited.
|
||||||
#pragma warning disable 4014
|
#pragma warning disable 4014
|
||||||
|
// Private items that are external can't start with an _
|
||||||
|
#pragma warning disable IDE1006
|
||||||
|
|
||||||
namespace Kyoo.Core.Controllers
|
namespace Kyoo.Core.Controllers
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<ProjectReference Include="../Kyoo.SqLite/Kyoo.SqLite.csproj" />
|
<ProjectReference Include="../Kyoo.SqLite/Kyoo.SqLite.csproj" />
|
||||||
<ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj" />
|
<ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj" />
|
||||||
<ProjectReference Include="../Kyoo.WebApp/Kyoo.WebApp.csproj" />
|
<ProjectReference Include="../Kyoo.WebApp/Kyoo.WebApp.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.Swagger/Kyoo.Swagger.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="BuildTranscoder" BeforeTargets="BeforeBuild" Condition="'$(SkipTranscoder)' != 'true' And !Exists('$(TranscoderRoot)/build/$(TranscoderBinary)')">
|
<Target Name="BuildTranscoder" BeforeTargets="BeforeBuild" Condition="'$(SkipTranscoder)' != 'true' And !Exists('$(TranscoderRoot)/build/$(TranscoderBinary)')">
|
||||||
|
@ -28,6 +28,7 @@ using Kyoo.Core.Models.Options;
|
|||||||
using Kyoo.Core.Tasks;
|
using Kyoo.Core.Tasks;
|
||||||
using Kyoo.Postgresql;
|
using Kyoo.Postgresql;
|
||||||
using Kyoo.SqLite;
|
using Kyoo.SqLite;
|
||||||
|
using Kyoo.Swagger;
|
||||||
using Kyoo.TheMovieDb;
|
using Kyoo.TheMovieDb;
|
||||||
using Kyoo.TheTvdb;
|
using Kyoo.TheTvdb;
|
||||||
using Kyoo.Utils;
|
using Kyoo.Utils;
|
||||||
@ -75,7 +76,8 @@ namespace Kyoo.Core
|
|||||||
typeof(PostgresModule),
|
typeof(PostgresModule),
|
||||||
typeof(SqLiteModule),
|
typeof(SqLiteModule),
|
||||||
typeof(PluginTvdb),
|
typeof(PluginTvdb),
|
||||||
typeof(PluginTmdb)
|
typeof(PluginTmdb),
|
||||||
|
typeof(SwaggerModule)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +208,7 @@ namespace Kyoo.Core.Api
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
[PartialPermission(Kind.Delete)]
|
[PartialPermission(Kind.Delete)]
|
||||||
public virtual async Task<IActionResult> Delete(Dictionary<string, string> where)
|
public virtual async Task<IActionResult> Delete(Dictionary<string, string> where)
|
||||||
{
|
{
|
||||||
|
@ -16,12 +16,68 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using Kyoo.Abstractions.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
namespace Kyoo.Swagger
|
namespace Kyoo.Swagger
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A module to enable a swagger interface and an OpenAPI endpoint to document Kyoo.
|
/// A module to enable a swagger interface and an OpenAPI endpoint to document Kyoo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SwaggerModule
|
public class SwaggerModule : IPlugin
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Slug => "swagger";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Name => "Swagger";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Description => "A swagger interface and an OpenAPI endpoint to document Kyoo.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Dictionary<string, Type> Configuration => new();
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Configure(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSwaggerGen(x =>
|
||||||
|
{
|
||||||
|
x.SwaggerDoc("v1", new OpenApiInfo
|
||||||
|
{
|
||||||
|
Version = "v1",
|
||||||
|
Title = "Kyoo API",
|
||||||
|
Description = "The Kyoo's public API",
|
||||||
|
Contact = new OpenApiContact
|
||||||
|
{
|
||||||
|
Name = "Kyoo's github",
|
||||||
|
Url = new Uri("https://github.com/AnonymusRaccoon/Kyoo/issues/new/choose")
|
||||||
|
},
|
||||||
|
License = new OpenApiLicense
|
||||||
|
{
|
||||||
|
Name = "GPL-3.0-or-later",
|
||||||
|
Url = new Uri("https://github.com/AnonymusRaccoon/Kyoo/blob/master/LICENSE")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (string documentation in Directory.GetFiles(AppContext.BaseDirectory, "*.xml"))
|
||||||
|
x.IncludeXmlComments(documentation);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IEnumerable<IStartupAction> ConfigureSteps => new IStartupAction[]
|
||||||
|
{
|
||||||
|
SA.New<IApplicationBuilder>(app => app.UseSwagger(), SA.Before + 1),
|
||||||
|
SA.New<IApplicationBuilder>(app => app.UseSwaggerUI(x =>
|
||||||
|
{
|
||||||
|
x.SwaggerEndpoint("/swagger/v1/swagger.json", "Kyoo v1");
|
||||||
|
}), SA.Before)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user