Swagger: Updating icons, cleaning up the openAPI spec and documenting the account endpoint

This commit is contained in:
Zoe Roux 2021-10-04 22:07:20 +02:00
parent a7a994ab41
commit 6ee5f3ef24
15 changed files with 78 additions and 9 deletions

View File

@ -9,7 +9,7 @@ AppUpdatesURL=https://github.com/AnonymusRaccoon/Kyoo
DefaultDirName={commonpf}\Kyoo
DisableProgramGroupPage=yes
LicenseFile={#kyoo}\LICENSE
SetupIconFile={#kyoo}\wwwroot\favicon.ico
SetupIconFile={#kyoo}\wwwroot\icon-256x256.png
Compression=lzma
SolidCompression=yes
WizardStyle=modern
@ -54,7 +54,7 @@ procedure InitializeWizard;
begin
DataDirPage := CreateInputDirPage(wpSelectDir,
'Choose Data Location', 'Choose the folder in which to install the Kyoo data',
'The installer will set the following folder for Kyoo. To install in a different folder, click Browse and select another folder.' +
'The installer will set the following folder for Kyoo. To install in a different folder, click Browse and select another folder.' +
'Please make sure the folder exists and is accessible. Do not choose the server install folder. Click Next to continue.',
False, '');
DataDirPage.Add('');
@ -64,4 +64,4 @@ end;
function GetDataDir(Param: String): String;
begin
Result := DataDirPage.Values[0];
end;
end;

BIN
icons/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
icons/icon-128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
icons/icon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

BIN
icons/icon-256x256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

BIN
icons/icon-256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
icons/icon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
icons/icon-64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -15,6 +15,8 @@
<PackageVersion>1.0.0</PackageVersion>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ApplicationIcon>$(MSBuildThisFileDirectory)../icons/icon-256x256.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>

View File

@ -0,0 +1,41 @@
// Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo.
//
// See AUTHORS.md and LICENSE file in the project root for full license information.
//
// Kyoo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// Kyoo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Authentication.Models.DTO
{
/// <summary>
/// A one time access token
/// </summary>
public class OtacResponse
{
/// <summary>
/// The One Time Access Token that allow one to connect to an account without typing a password or without
/// any kind of verification. This is valid only one time and only for a short period of time.
/// </summary>
public string OTAC { get; set; }
/// <summary>
/// Create a new <see cref="OtacResponse"/>.
/// </summary>
/// <param name="otac">The one time access token.</param>
public OtacResponse(string otac)
{
OTAC = otac;
}
}
}

View File

@ -28,6 +28,7 @@ using IdentityServer4.Models;
using IdentityServer4.Services;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Abstractions.Models.Exceptions;
using Kyoo.Abstractions.Models.Utils;
using Kyoo.Authentication.Models;
@ -43,10 +44,13 @@ namespace Kyoo.Authentication.Views
{
/// <summary>
/// The endpoint responsible for login, logout, permissions and claims of a user.
/// Documentation of this endpoint is a work in progress.
/// </summary>
/// TODO document this well.
[Route("api/accounts")]
[Route("api/account", Order = AlternativeRoute)]
[ApiController]
[ApiDefinition("Account")]
public class AccountApi : Controller, IProfileService
{
/// <summary>
@ -90,7 +94,7 @@ namespace Kyoo.Authentication.Views
[HttpPost("register")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status409Conflict, Type = typeof(RequestError))]
public async Task<IActionResult> Register([FromBody] RegisterRequest request)
public async Task<ActionResult<OtacResponse>> Register([FromBody] RegisterRequest request)
{
User user = request.ToUser();
user.Permissions = _options.Value.Permissions.NewUser;
@ -106,7 +110,7 @@ namespace Kyoo.Authentication.Views
return Conflict(new RequestError("A user with this name already exists"));
}
return Ok(new { Otac = user.ExtraData["otac"] });
return Ok(new OtacResponse(user.ExtraData["otac"]));
}
/// <summary>
@ -126,8 +130,11 @@ namespace Kyoo.Authentication.Views
}
/// <summary>
/// Login the user.
/// Login
/// </summary>
/// <remarks>
/// Login the current session.
/// </remarks>
/// <param name="login">The DTO login request</param>
/// <returns>TODO</returns>
[HttpPost("login")]

View File

@ -59,7 +59,7 @@ namespace Kyoo.Swagger
});
}
if (def == null)
if (def?.Group == null)
return true;
context.Document.ExtensionData ??= new Dictionary<string, object>();

View File

@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
@ -58,7 +59,7 @@ namespace Kyoo.Swagger
document.Title = "Kyoo API";
// TODO use a real multi-line description in markdown.
document.Description = "The Kyoo's public API";
document.Version = "1.0.0";
document.Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString(3);
document.DocumentName = "v1";
document.UseControllerSummaryAsTagDescription = true;
document.GenerateExamples = true;
@ -74,6 +75,14 @@ namespace Kyoo.Swagger
Name = "GPL-3.0-or-later",
Url = "https://github.com/AnonymusRaccoon/Kyoo/blob/master/LICENSE"
};
options.Info.ExtensionData ??= new Dictionary<string, object>();
options.Info.ExtensionData["x-logo"] = new
{
url = "/banner.png",
backgroundColor = "#FFFFFF",
altText = "Kyoo's logo"
};
};
document.UseApiTags();
document.SortApis();
@ -129,6 +138,10 @@ namespace Kyoo.Swagger
SA.New<IApplicationBuilder>(app => app.UseReDoc(x =>
{
x.Path = "/redoc";
x.AdditionalSettings["theme"] = new
{
colors = new { primary = new { main = "#e13e13" } }
};
}), SA.Before)
};
}

@ -1 +1 @@
Subproject commit a3da5f1e6edb982e3b71792a7ea6fcd45661c337
Subproject commit 7bf53b40080d1d43228f1cdcad510b302ead99ff

View File

@ -12,6 +12,7 @@
<IsPackable>false</IsPackable>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules/**</DefaultItemExcludes>
<SpaRoot>Front/</SpaRoot>
<Icons>../../icons/</Icons>
<NpmStamp>$(SpaRoot)node_modules/.install-stamp</NpmStamp>
<!-- Set this to true if you enable server-side prerendering -->
@ -29,6 +30,11 @@
<Compile Remove="$(SpaRoot)**" />
<None Remove="$(SpaRoot)dist/**; $(SpaRoot)dist-server/**" />
<Content Include="$(Icons)**" Visible="false">
<Link>wwwroot/%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="$(SpaRoot)static/**" Visible="false">
<Link>wwwroot/%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>