Improves OpenApi documentation

This commit is contained in:
BinaryAlley committed 2024-11-15 21:01:19 +02:00
1 parent f2703b86c5
commit 77f95708b9
101 files changed
+2336 -294

No files matched your search

@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Mediator;
using System.Diagnostics;
@@ -15,4 +16,4 @@ namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathEx
public record CheckPathExistsQuery(
string? Path,
bool IncludeHiddenElements
) : IRequest<PathExistsResponse>;
) : IRequest<ErrorOr<PathExistsResponse>>;
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Mediator;
@@ -11,7 +12,7 @@ namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathEx
/// <summary>
/// Handler for the query to check the existence a file system path.
/// </summary>
public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery, PathExistsResponse>
public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery, ErrorOr<PathExistsResponse>>
{
private readonly IPathService _pathService;
@@ -30,10 +31,10 @@ public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery,
/// <param name="request">The query containing the request.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// <see langword="true"/> if the specified path exists, <see langword="false"/> otherwise.
/// An <see cref="ErrorOr{TValue}"/> containing either <see langword="true"/> if the specified path exists, <see langword="false"/> if it doesn't, or an error message.
/// </returns>
public ValueTask<PathExistsResponse> Handle(CheckPathExistsQuery request, CancellationToken cancellationToken)
public ValueTask<ErrorOr<PathExistsResponse>> Handle(CheckPathExistsQuery request, CancellationToken cancellationToken)
{
return ValueTask.FromResult(new PathExistsResponse(_pathService.Exists(request.Path!, request.IncludeHiddenElements)));
return ValueTask.FromResult(ErrorOrFactory.From(new PathExistsResponse(_pathService.Exists(request.Path!, request.IncludeHiddenElements))));
}
}
@@ -7,9 +7,9 @@ namespace Lumina.Contracts.DTO.Common;
/// <summary>
/// Data transfer object for language information.
/// </summary>
/// <param name="LanguageCode">Gets the ISO code of the language (e.g., "en" for English).</param>
/// <param name="LanguageName">Gets the name of the language in English.</param>
/// <param name="NativeName">Gets the native name of the language (e.g., "Español" for Spanish).</param>
/// <param name="LanguageCode">Gets the ISO code of the language (e.g., "en" for English). Required.</param>
/// <param name="LanguageName">Gets the name of the language in English. Required.</param>
/// <param name="NativeName">Gets the native name of the language (e.g., "Español" for Spanish). Optional.</param>
[DebuggerDisplay("LanguageName: {LanguageName}")]
public record LanguageInfoDto(
string? LanguageCode,
@@ -8,12 +8,12 @@ namespace Lumina.Contracts.DTO.Common;
/// <summary>
/// Data transfer object for a release information.
/// </summary>
/// <param name="OriginalReleaseDate">Gets the original release date of the content.</param>
/// <param name="OriginalReleaseYear">Gets the original release year of the content.</param>
/// <param name="ReReleaseDate">Gets the re-release date of the content, if applicable.</param>
/// <param name="ReReleaseYear">Gets the re-release year of the content, if applicable.</param>
/// <param name="ReleaseCountry">Gets the country where the content was released.</param>
/// <param name="ReleaseVersion">Gets the version or edition of the content's release.</param>
/// <param name="OriginalReleaseDate">Gets the original release date of the content. Optional.</param>
/// <param name="OriginalReleaseYear">Gets the original release year of the content. Optional.</param>
/// <param name="ReReleaseDate">Gets the re-release date of the content. Optional.</param>
/// <param name="ReReleaseYear">Gets the re-release year of the content. Optional.</param>
/// <param name="ReleaseCountry">Gets the country where the content was released. Optional.</param>
/// <param name="ReleaseVersion">Gets the version or edition of the content's release. Optional.</param>
[DebuggerDisplay("OriginalReleaseDate: {OriginalReleaseDate}")]
public record ReleaseInfoDto(
DateOnly? OriginalReleaseDate,
@@ -9,16 +9,16 @@ namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
/// <summary>
/// Data transfer object for written content metadata.
/// </summary>
/// <param name="Title">The title of the written content.</param>
/// <param name="OriginalTitle">The original title of the written content, if different from the current title.</param>
/// <param name="Description">Gets a brief description or summary of the written content.</param>
/// <param name="ReleaseInfo">The release information, including release date and other relevant details.</param>
/// <param name="Genres">The list of genres associated with the written content.</param>
/// <param name="Tags">The list of tags that further describe or categorize the written content.</param>
/// <param name="Language">The language in which the written content is written.</param>
/// <param name="OriginalLanguage">The original language of the written content, if it has been translated.</param>
/// <param name="Publisher">The name of the publisher of the written content.</param>
/// <param name="PageCount">The number of pages in the written content.</param>
/// <param name="Title">The title of the written content. Required.</param>
/// <param name="OriginalTitle">The original title of the written content, if different from the current title. Optional.</param>
/// <param name="Description">Gets a brief description or summary of the written content. Optional.</param>
/// <param name="ReleaseInfo">The release information, including release date and other relevant details. Required.</param>
/// <param name="Genres">The list of genres associated with the written content. Required.</param>
/// <param name="Tags">The list of tags that further describe or categorize the written content. Required.</param>
/// <param name="Language">The language in which the written content is written. Optional.</param>
/// <param name="OriginalLanguage">The original language of the written content, if it has been translated. Optional.</param>
/// <param name="Publisher">The name of the publisher of the written content. Optional.</param>
/// <param name="PageCount">The number of pages in the written content. Optional.</param>
[DebuggerDisplay("Title: {Title}")]
public record WrittenContentMetadataDto(
string? Title,
@@ -13,6 +13,10 @@
<Compile Include="..\AssemblyInfo_Shared.cs" Link="Properties\AssemblyInfo_Shared.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FastEndpoints.Swagger" Version="5.31.0.6-beta" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lumina.Domain\Lumina.Domain.csproj" />
</ItemGroup>
@@ -3,10 +3,10 @@ namespace Lumina.Contracts.Requests.Authentication;
/// <summary>
/// Represents the request model for account password change.
/// </summary>
/// <param name="CurrentPassword">The username of the account.</param>
/// <param name="CurrentPassword">The current password of the account.</param>
/// <param name="NewPassword">The new password of the account.</param>
/// <param name="NewPasswordConfirm">The confirmation of the new password of the account.</param>
/// <param name="Username">The username of the account. Required.</param>
/// <param name="CurrentPassword">The current password of the account. Required.</param>
/// <param name="NewPassword">The new password of the account. Required.</param>
/// <param name="NewPasswordConfirm">The confirmation of the new password of the account. Required.</param>
public record ChangePasswordRequest(
string? Username,
string? CurrentPassword,
@@ -7,9 +7,9 @@ namespace Lumina.Contracts.Requests.Authentication;
/// <summary>
/// Represents the request model for user authentication.
/// </summary>
/// <param name="Username">The username of the account to authenticate.</param>
/// <param name="Password">The password of the account to authenticate.</param>
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account to authenticate.</param>
/// <param name="Username">The username of the account to authenticate. Required.</param>
/// <param name="Password">The password of the account to authenticate. Required.</param>
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account to authenticate. Optional.</param>
[DebuggerDisplay("Username: {Username}")]
public record LoginRequest(
string? Username,
@@ -7,8 +7,8 @@ namespace Lumina.Contracts.Requests.Authentication;
/// <summary>
/// Represents the request model for account password recovery.
/// </summary>
/// <param name="Username">The username of the account for which to recover the password.</param>
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account for which to recover the password.</param>
/// <param name="Username">The username of the account for which to recover the password. Required.</param>
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account for which to recover the password. Required.</param>
[DebuggerDisplay("Username: {Username}")]
public record RecoverPasswordRequest(
string? Username,
@@ -7,10 +7,10 @@ namespace Lumina.Contracts.Requests.Authentication;
/// <summary>
/// Represents the request model for user registration.
/// </summary>
/// <param name="Username">The desired username for the new account.</param>
/// <param name="Password">The password for the new account.</param>
/// <param name="PasswordConfirm">The confirmation of the entered password, used to ensure consistency.</param>
/// <param name="Use2fa">Indicates whether two-factor authentication (2FA) should be enabled for the new account.</param>
/// <param name="Username">The desired username for the new account. Required.</param>
/// <param name="Password">The password for the new account. Required.</param>
/// <param name="PasswordConfirm">The confirmation of the entered password, used to ensure consistency. Required.</param>
/// <param name="Use2fa">Indicates whether two-factor authentication (2FA) should be enabled for the new account. Optional.</param>
[DebuggerDisplay("Username: {Username}")]
public record RegistrationRequest(
string? Username = null,
@@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Directories;
/// <summary>
/// Represents a request to get the directories of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the directories.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <param name="Path">The file system path for which to get the directories. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetDirectoriesRequest(
string? Path,
@@ -8,9 +8,9 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Directories;
/// <summary>
/// Represents a request to get the tree of directories that make up a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the directory tree.</param>
/// <param name="IncludeFiles">Whether to include files along the directories or not.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <param name="Path">The file system path for which to get the directory tree. Required.</param>
/// <param name="IncludeFiles">Whether to include files along the directories or not. Optional.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetDirectoryTreeRequest(
string? Path,
@@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Directories;
/// <summary>
/// Represents a request to get the directories of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the directory tree.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <param name="Path">The file system path for which to get the directory tree. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetTreeDirectoriesRequest(
string? Path,
@@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Files;
/// <summary>
/// Represents a request to get the files at a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the files.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <param name="Path">The file system path for which to get the files. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetFilesRequest(
string? Path,
@@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Files;
/// <summary>
/// Represents a request to get the files of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the tree files.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
/// <param name="Path">The file system path for which to get the tree files. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetTreeFilesRequest(
string? Path,
@@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to check the existence of a file system path.
/// </summary>
/// <param name="Path">The file system path to check the exitence of.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden elements in the search results, or not.</param>
/// <param name="Path">The file system path to check the exitence of. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden elements in the search results, or not. Optional.</param>
[DebuggerDisplay("Path: {Path}, IncludeHiddenElements: {IncludeHiddenElements}")]
public record CheckPathExistsRequest(
string? Path,
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
using System.Text.Json.Serialization;
#endregion
namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
@@ -8,8 +7,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to get the root of a file system path.
/// </summary>
/// <param name="OriginalPath">The file system path to combine to.</param>
/// <param name="NewPath">The file system path to combine with.</param>
/// <param name="OriginalPath">The file system path to combine to. Required.</param>
/// <param name="NewPath">The file system path to combine with. Required.</param>
[DebuggerDisplay("OriginalPath: {OriginalPath}, NewPath: {NewPath}")]
public record CombinePathRequest(
string? OriginalPath,
@@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to get the root of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the root.</param>
/// <param name="Path">The file system path for which to get the root. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetPathParentRequest(
string? Path
@@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to get the root of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the root.</param>
/// <param name="Path">The file system path for which to get the root. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetPathRootRequest(
string? Path
@@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to split a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the path segments.</param>
/// <param name="Path">The file system path for which to get the path segments. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record SplitPathRequest(
string? Path
@@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to check the validity of a file system path.
/// </summary>
/// <param name="Path">The file system path to validate.</param>
/// <param name="Path">The file system path to validate. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record ValidatePathRequest(
string? Path
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
using System.Text.Json.Serialization;
#endregion
namespace Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
@@ -9,10 +9,10 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
/// <summary>
/// Represents a request to add a media library.
/// </summary>
/// <param name="UserId">The Id of the user owning the media library.</param>
/// <param name="Title">The title of the media library.</param>
/// <param name="LibraryType">The type of the media library.</param>
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located.</param>
/// <param name="UserId">The Id of the user owning the media library. Required.</param>
/// <param name="Title">The title of the media library. Required.</param>
/// <param name="LibraryType">The type of the media library. Required.</param>
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located. Required.</param>
[DebuggerDisplay("Title: {Title}")]
public record AddLibraryRequest(
Guid UserId,
@@ -12,23 +12,23 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
/// <summary>
/// Represents a request to add a book.
/// </summary>
/// <param name="Metadata">Written content metadata of the book.</param>
/// <param name="Format">The format of the book (e.g., Hardcover, Paperback), if applicable.</param>
/// <param name="Edition">The edition of the book, if applicable.</param>
/// <param name="VolumeNumber">The volume or book number in the series, if applicable.</param>
/// <param name="Series">The series name, if the book is part of a series.</param>
/// <param name="ASIN">The ASIN (Amazon Standard Identification Number) of the book, if applicable.</param>
/// <param name="GoodreadsId">The Goodreads ID of the book, if applicable.</param>
/// <param name="LCCN">The Library of Congress Control Number (LCCN) of the book, if applicable.</param>
/// <param name="OCLCNumber">The OCLC Number (WorldCat identifier) of the book, if applicable.</param>
/// <param name="OpenLibraryId">The Open Library ID of the book, if applicable.</param>
/// <param name="LibraryThingId">The LibraryThing ID of the book, if applicable.</param>
/// <param name="GoogleBooksId">The Google Books ID of the book, if applicable.</param>
/// <param name="BarnesAndNobleId">The Barnes & Noble ID of the book, if applicable.</param>
/// <param name="AppleBooksId">The Apple Books ID of the book, if applicable.</param>
/// <param name="ISBNs">The list of ISBN (International Standard Book Number) of the book.</param>
/// <param name="Contributors">The list of media contributors (actors, directors, etc) starring in this book.</param>
/// <param name="Ratings">The list of ratings for this book.</param>
/// <param name="Metadata">Written content metadata of the book. Required.</param>
/// <param name="Format">The format of the book (e.g., Hardcover, Paperback). Optional.</param>
/// <param name="Edition">The edition of the book. Optional.</param>
/// <param name="VolumeNumber">The volume or book number in the series. Optional.</param>
/// <param name="Series">The series name, if the book is part of a series. Optional.</param>
/// <param name="ASIN">The ASIN (Amazon Standard Identification Number) of the book. Optional.</param>
/// <param name="GoodreadsId">The Goodreads Id of the book. Optional.</param>
/// <param name="LCCN">The Library of Congress Control Number (LCCN) of the book. Optional.</param>
/// <param name="OCLCNumber">The OCLC Number (WorldCat identifier) of the book. Optional.</param>
/// <param name="OpenLibraryId">The Open Library Id of the book. Optional.</param>
/// <param name="LibraryThingId">The LibraryThing Id of the book. Optional.</param>
/// <param name="GoogleBooksId">The Google Books Id of the book. Optional.</param>
/// <param name="BarnesAndNobleId">The Barnes & Noble Id of the book. Optional.</param>
/// <param name="AppleBooksId">The Apple Books Id of the book. Optional.</param>
/// <param name="ISBNs">The list of ISBN (International Standard Book Number) of the book. Required.</param>
/// <param name="Contributors">The list of media contributors (actors, directors, etc) starring in this book. Required.</param>
/// <param name="Ratings">The list of ratings for this book. Required.</param>
[DebuggerDisplay("Title: {Metadata.Title}")]
public record AddBookRequest(
WrittenContentMetadataDto? Metadata,
@@ -79,7 +79,7 @@ public static class PresentationApiLayerServices
title = "TooManyRequests", // TODO: implement translation?
status = StatusCodes.Status429TooManyRequests,
detail = "Too many attempts. Please try again later.",
retryAfter = "15"
retryAfter = "900"
};
await onRejectedContext.HttpContext.Response.WriteAsJsonAsync(problem, cancellationToken);
@@ -125,14 +125,35 @@ public static class PresentationApiLayerServices
// set the response status code to 401 Unauthorized
jwtBearerChallengeContext.Response.StatusCode = StatusCodes.Status401Unauthorized;
jwtBearerChallengeContext.Response.ContentType = "application/problem+json";
IProblemDetailsService problemDetailsService = jwtBearerChallengeContext.HttpContext.RequestServices.GetRequiredService<IProblemDetailsService>();
string errorDetails = "Authentication failed";
if (!string.IsNullOrEmpty(jwtBearerChallengeContext.Error))
{
errorDetails = jwtBearerChallengeContext.Error switch
{ // TODO: implement translation
"invalid_token" => !string.IsNullOrEmpty(jwtBearerChallengeContext.ErrorDescription)
? $"Invalid token: {jwtBearerChallengeContext.ErrorDescription}"
: "The token is invalid",
"expired_token" => "The token has expired",
_ => $"Authentication failed{(jwtBearerChallengeContext.Error is not null ? ": " + jwtBearerChallengeContext.Error : string.Empty)}"
};
}
string detail = jwtBearerChallengeContext.Error switch
{
"invalid_token" => !string.IsNullOrEmpty(jwtBearerChallengeContext.ErrorDescription)
? $"Invalid token: {jwtBearerChallengeContext.ErrorDescription}"
: "The token is invalid",
"expired_token" => "The token has expired",
_ => $"Authentication failed{(jwtBearerChallengeContext.Error is not null ? ": " + jwtBearerChallengeContext.Error : string.Empty)}"
};
return jwtBearerChallengeContext.Response.WriteAsJsonAsync(new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = StatusCodes.Status401Unauthorized,
title = "Unauthorized",
detail = "You are not authorized",
detail,
instance = jwtBearerChallengeContext.HttpContext.Request.Path
});
}
@@ -94,10 +94,10 @@ public abstract class BaseEndpoint<TRequest, TResponse> : Endpoint<TRequest, TRe
// return a validation problem result with the constructed error details
return Results.ValidationProblem(
errorsDictionary,
detail: "One or more validation errors occurred.", // TODO: implement translation?
detail: "OneOrMoreValidationErrorsOccurred",
instance: HttpContext.Request.Path,
statusCode: 422,
title: "Validation Error",
title: "General.Validation",
extensions: extensionsDictionary
);
}
@@ -40,7 +40,6 @@ public class GetDirectoriesEndpoint : BaseEndpoint<GetDirectoriesRequest, IResul
Verbs(Http.GET);
Routes(ApiRoutes.Directories.GET_DIRECTORIES);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -22,10 +23,85 @@ public class GetDirectoriesEndpointSummary : Summary<GetDirectoriesEndpoint, Get
Summary = "Retrieves the list of directories for a specified file system path.";
Description = "Returns the directories within the specified path, with an option to include hidden file system elements.";
RequestParam(r => r.Path, "The file system path for which to get the directories.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
ExampleRequest = new GetDirectoriesRequest(
Path: "/media/movies/",
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetDirectoriesRequest(
Path: "/media/movies/",
IncludeHiddenElements: false
)));
Response<IEnumerable<DirectoryResponse>>(200, "The list of directories for the specified path is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path for which to get the directories. Required.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The list of directories for the specified path is returned.",
example: new DirectoryResponse[] {
new(Path: "/media/movies/The Matrix (1999)/", Name: "The Matrix", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: []),
new(Path: "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name: "The Lord of the Rings - The Fellowship of the Ring (2001)", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [])
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/directories/get-directories"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/directories/get-directories"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/directories/get-directories"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/directories/get-directories",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/directories/get-directories",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -40,7 +40,6 @@ public class GetDirectoryTreeEndpoint : BaseEndpoint<GetDirectoryTreeRequest, IR
Verbs(Http.GET);
Routes(ApiRoutes.Directories.GET_DIRECTORY_TREE);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -22,11 +23,167 @@ public class GetDirectoryTreeEndpointSummary : Summary<GetDirectoryTreeEndpoint,
Summary = "Retrieves the directory tree structure for a specified file system path.";
Description = "Returns a hierarchical view of the directory tree, with options to include files and hidden elements.";
RequestParam(r => r.Path, "The file system path for which to get the directory tree.");
RequestParam(r => r.IncludeFiles, "Whether to include files along the directories or not.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
ExampleRequest = new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: true,
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: false,
IncludeHiddenElements: false
)));
RequestExamples.Add(new RequestExample(new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: true,
IncludeHiddenElements: false
)));
RequestExamples.Add(new RequestExample(new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: false,
IncludeHiddenElements: true
)));
Response<IEnumerable<FileSystemTreeNodeResponse>>(200, "The directory tree structure for the specified path.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path for which to get the directory tree. Required.");
RequestParam(r => r.IncludeFiles, "Whether to include files along the directories or not. Optional.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The directory tree structure for the specified path.",
example: new FileSystemTreeNodeResponse[] {
new()
{
Path = "/",
Name = "The Lord of the Rings - The Fellowship of the Ring (2001)",
ItemType = FileSystemItemType.Root,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/",
Name = "media",
ItemType = FileSystemItemType.Directory,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/movies/",
Name = "movies",
ItemType = FileSystemItemType.Directory,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/",
Name = "The Lord of the Rings - The Fellowship of the Ring (2001)",
ItemType = FileSystemItemType.Directory,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/Extras/",
Name = "Extras",
ItemType = FileSystemItemType.Directory,
IsExpanded = false,
ChildrenLoaded = false,
Children = []
},
new()
{
Path = "/media/movies/The Matrix (1999)/The Matrix.mkv",
Name = "The Matrix.mkv",
ItemType = FileSystemItemType.File,
IsExpanded = false,
ChildrenLoaded = false,
Children = []
},
new()
{
Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt",
Name = "The Matrix.en.srt",
ItemType = FileSystemItemType.File,
IsExpanded = false,
ChildrenLoaded = false,
Children = []
}
]
},
]
},
]
},
]
},
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/directories/get-directory-tree"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/directories/get-directory-tree"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/directories/get-directory-tree"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/directories/get-directory-tree",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/directories/get-directory-tree",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -39,7 +39,6 @@ public class GetTreeDirectoriesEndpoint : BaseEndpoint<GetTreeDirectoriesRequest
Verbs(Http.GET);
Routes(ApiRoutes.Directories.GET_TREE_DIRECTORIES);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -22,10 +23,85 @@ public class GetTreeDirectoriesEndpointSummary : Summary<GetTreeDirectoriesEndpo
Summary = "Retrieves the directory tree structure for the specified file system path.";
Description = "Returns the directory tree structure, with an option to include hidden file system elements.";
RequestParam(r => r.Path, "The file system path for which to get the directory tree.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
ExampleRequest = new GetTreeDirectoriesRequest(
Path: "/media/movies/",
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetTreeDirectoriesRequest(
Path: "/media/movies/",
IncludeHiddenElements: false
)));
Response<IEnumerable<FileSystemTreeNodeResponse>>(200, "The directory tree structure is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path for which to get the directory tree. Required.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The directory tree structure is returned.",
example: new FileSystemTreeNodeResponse[] {
new() { Path = "/media/movies/The Matrix (1999)/", Name = "The Matrix (1999)", ItemType = FileSystemItemType.Directory, IsExpanded = false, ChildrenLoaded = false, Children = [] },
new() { Path = "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name = "The Lord of the Rings - The Fellowship of the Ring (2001)", ItemType = FileSystemItemType.Directory, IsExpanded = false, ChildrenLoaded = false, Children = [] },
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/directories/get-tree-directories"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/directories/get-tree-directories"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/directories/get-tree-directories"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/directories/get-tree-directories",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/directories/get-tree-directories",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -38,7 +38,6 @@ public class GetDrivesEndpoint : BaseEndpoint<EmptyRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Drives.GET_DRIVES);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -21,6 +22,41 @@ public class GetDrivesEndpointSummary : Summary<GetDrivesEndpoint>
Summary = "Retrieves the list of file system drives.";
Description = "Returns all available drives in the file system, on Windows, or the root path, on UNIX.";
Response<IEnumerable<FileSystemTreeNodeResponse>>(200, "The list of file system drives is returned.");
Response(200, "The list of file system drives is returned.",
example: new FileSystemTreeNodeResponse[] {
new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] },
new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] }
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/drives/get-drives"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/drives/get-drives"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/drives/get-drives"
}
}
);
}
}
@@ -40,7 +40,6 @@ public class GetTypeEndpoint : BaseEndpoint<EmptyRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.FileSystem.GET_TYPES);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -10,7 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.FileSystem
/// Class used for providing a textual description for the <see cref="GetTypeEndpoint"/> API endpoint, for Swagger.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTypeEndpointSummary : Summary<GetTypeEndpoint>
public class GetTypeEndpointSummary : Summary<GetTypeEndpoint, FileSystemTypeResponse>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetTypeEndpointSummary"/> class.
@@ -20,6 +21,39 @@ public class GetTypeEndpointSummary : Summary<GetTypeEndpoint>
Summary = "Gets the type of the file system.";
Description = "Returns the type of the file system.";
Response<FileSystemTypeResponse>(200, "The file system type is returned.");
Response(200, "The file system type is returned.",
example: new FileSystemTypeResponse(
PlatformType: PlatformType.Unix
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/file-system/get-type"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/file-system/get-type"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/file-system/get-type"
}
}
);
}
}
@@ -39,7 +39,6 @@ public class GetFilesEndpoint : BaseEndpoint<GetFilesRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Files.GET_FILES);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,8 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Contracts.Responses.FileSystemManagement.Files;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -22,10 +24,85 @@ public class GetFilesEndpointSummary : Summary<GetFilesEndpoint, GetFilesRequest
Summary = "Retrieves the list of files for a specified file system path.";
Description = "Returns the files within the specified path, with an option to include hidden file system elements.";
RequestParam(r => r.Path, "The file system path for which to get the files.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
ExampleRequest = new GetFilesRequest(
Path: "/media/movies/",
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetFilesRequest(
Path: "/media/movies/",
IncludeHiddenElements: false
)));
Response<IEnumerable<FileSystemTreeNodeResponse>>(200, "The list of files is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path for which to get the files. Required.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The list of files is returned.",
example: new FileResponse[] {
new(Path: "/media/movies/The Matrix (1999)/The Matrix.mkv", Name: "The Matrix.mkv", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 754045401),
new(Path: "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name: "The Matrix.en.srt", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 6897)
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/files/get-files"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/files/get-files"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/files/get-files"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/files/get-files",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/files/get-files",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -39,7 +39,6 @@ public class GetTreeFilesEndpoint : BaseEndpoint<GetTreeFilesRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Files.GET_TREE_FILES);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -22,10 +23,86 @@ public class GetTreeFilesEndpointSummary : Summary<GetTreeFilesEndpoint, GetTree
Summary = "Retrieves the tree structure of files for a specified file system path.";
Description = "Returns the files within the specified path in a hierarchical tree structure, with an option to include hidden file system elements.";
RequestParam(r => r.Path, "The file system path for which to get the tree files.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
ExampleRequest = new GetTreeFilesRequest(
Path: "/media/movies/",
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetTreeFilesRequest(
Path: "/media/movies/",
IncludeHiddenElements: false
)));
Response<IEnumerable<FileSystemTreeNodeResponse>>(200, "The tree structure of files is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path for which to get the tree files. Required.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The tree structure of files is returned.",
example: new FileSystemTreeNodeResponse[] {
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.mkv", Name = "The Matrix.mkv", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name = "The Matrix.en.srt", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
new() { Path = "/media/movies/The Matrix (1999)/poster.jpg", Name = "poster.jpg", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/files/get-tree-files"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/files/get-tree-files"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/files/get-tree-files"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/files/get-tree-files",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/files/get-tree-files",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
@@ -37,7 +38,6 @@ public class CheckPathExistsEndpoint : BaseEndpoint<CheckPathExistsRequest, IRes
Verbs(Http.GET);
Routes(ApiRoutes.Path.CHECK_PATH_EXISTS);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -48,7 +48,7 @@ public class CheckPathExistsEndpoint : BaseEndpoint<CheckPathExistsRequest, IRes
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(CheckPathExistsRequest request, CancellationToken cancellationToken)
{
PathExistsResponse result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return TypedResults.Ok(result);
ErrorOr<PathExistsResponse> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -3,6 +3,7 @@ using FastEndpoints;
using FastEndpoints.Swagger;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -22,10 +23,72 @@ public class CheckPathExistsEndpointSummary : Summary<CheckPathExistsEndpoint, C
Summary = "Checks the existence of a file system path.";
Description = "Verifies if the specified file system path exists, with an option to include hidden elements in the search.";
RequestParam(r => r.Path, "The file system path to check the exitence of.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden elements in the search results, or not.");
ExampleRequest = new CheckPathExistsRequest(
Path: "/media/movies/",
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new CheckPathExistsRequest(
Path: "/media/movies/",
IncludeHiddenElements: false
)));
Response<PathSegmentResponse>(200, "Indicates whether the file system path exists.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path to check the exitence of. Required.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden elements in the search results, or not. Optional.");
Response(200, "Indicates whether the file system path exists.",
example: new PathExistsResponse(
Exists: true
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/check-path-exists"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/check-path-exists"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/check-path-exists"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/path/check-path-exists",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -38,7 +38,6 @@ public class CombinePathEndpoint : BaseEndpoint<CombinePathRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Path.COMBINE);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -21,10 +22,68 @@ public class CombinePathEndpointSummary : Summary<CombinePathEndpoint, CombinePa
Summary = "Combines two file system paths.";
Description = "Combines the specified original path with a new path to form a single file system path.";
RequestParam(r => r.OriginalPath, "The file system path to combine to.");
RequestParam(r => r.NewPath, "The file system path to combine with.");
ExampleRequest = new CombinePathRequest(
OriginalPath: "/media",
NewPath: "movies"
);
Response<PathSegmentResponse>(200, "Successfully combined the paths.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.OriginalPath, "The file system path to combine to. Required.");
RequestParam(r => r.NewPath, "The file system path to combine with. Required.");
Response(200, "The combined paths are returned.",
example: new PathSegmentResponse(
Path: "/media/movies/"
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/combine"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/combine"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/combine"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/path/combine",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -39,7 +39,6 @@ public class GetPathParentEndpoint : BaseEndpoint<GetPathParentRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Path.GET_PATH_PARENT);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -22,9 +22,79 @@ public class GetPathParentEndpointSummary : Summary<GetPathParentEndpoint, GetPa
Summary = "Retrieves the parent directory of the requested file system path.";
Description = "Fetches the parent directory of a specified file system path, if available.";
RequestParam(r => r.Path, "The path for which to get the parent directory.");
ExampleRequest = new GetPathParentRequest(
Path: "/media/movies/"
);
Response<IEnumerable<PathSegmentResponse>>(200, "The parent directory of the requested path is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The path for which to get the parent directory. Required.");
Response(200, "The parent directory of the requested path is returned.",
example: new PathSegmentResponse[] {
new("/"),
new("media")
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/get-path-parent"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/get-path-parent"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/get-path-parent"
}
}
);
Response(403, "The request failed because the provided path has no parent.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "CannotNavigateUp",
instance = "/api/v1/path/get-path-parent",
traceId = "00-612a168d318340949b326a8598161059-310ff12684509b92-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/path/get-path-parent",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -38,7 +38,6 @@ public class GetPathRootEndpoint : BaseEndpoint<GetPathRootRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Path.GET_PATH_ROOT);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -20,10 +21,67 @@ public class GetPathRootEndpointSummary : Summary<GetPathRootEndpoint, GetPathRo
{
Summary = "Retrieves a file system path root segment.";
Description = "Fetches the root segment of a specified file system path, using the provided path parameter.";
RequestParam(r => r.Path, "The file system path for which to get the root.");
Response<PathSegmentResponse>(200, "The root of the requested path is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
ExampleRequest = new GetPathRootRequest(
Path: "/media/movies/"
);
RequestParam(r => r.Path, "The file system path for which to get the root. Required.");
Response(200, "The root of the requested path is returned.",
example: new PathSegmentResponse(
Path: "/"
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/get-path-root"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/get-path-root"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/get-path-root"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/path/get-path-root",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -35,7 +35,6 @@ public class GetPathSeparatorEndpoint : EndpointWithoutRequest<IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Path.GET_PATH_SEPARATOR);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -20,6 +20,39 @@ public class GetPathSeparatorEndpointSummary : Summary<GetPathSeparatorEndpoint>
Summary = "Retrieves the file system path separator character.";
Description = "Fetches the path separator character for the current file system that the API is running on.";
Response<PathSeparatorResponse>(200, "The path separator character is returned.");
Response(200, "The path separator character is returned.",
example: new PathSeparatorResponse(
Separator: "/"
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/get-path-separator"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/get-path-separator"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/get-path-separator"
}
}
);
}
}
@@ -39,7 +39,6 @@ public class SplitPathEndpoint : BaseEndpoint<SplitPathRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Path.SPLIT);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -22,9 +22,68 @@ public class SplitPathEndpointSummary : Summary<SplitPathEndpoint, SplitPathRequ
Summary = "Splits a file system path.";
Description = "Splits a file system path into its constituent segments.";
RequestParam(r => r.Path, "The file system path for which to get the path segments.");
ExampleRequest = new SplitPathRequest(
Path: "/media/movies/"
);
Response<IEnumerable<PathSegmentResponse>>(200, "Successfully split the path into segments.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path for which to get the path segments. Required.");
Response(200, "Successfully split the path into segments.",
example: new PathSegmentResponse[2] {
new(Path: "media"),
new(Path: "movies")
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/split"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/split"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/split"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/path/split",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -37,7 +37,6 @@ public class ValidatePathEndpoint : BaseEndpoint<ValidatePathRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Path.VALIDATE);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -21,9 +22,66 @@ public class ValidatePathEndpointSummary : Summary<ValidatePathEndpoint, Validat
Summary = "Validates a file system path.";
Description = "Checks if the specified file system path is valid according to predefined criteria.";
RequestParam(r => r.Path, "The file system path to validate.");
ExampleRequest = new ValidatePathRequest(
Path: "/media/movies/"
);
Response<PathValidResponse>(200, "The requested path is validated.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Path, "The file system path to validate. Required.");
Response(200, "The requested path is validated.",
example: new PathValidResponse(
IsValid: true
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/path/validate"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/path/validate"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/path/validate"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/path/validate",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -40,7 +40,6 @@ public class GetThumbnailEndpoint : BaseEndpoint<GetThumbnailRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Thumbnails.GET_THUMBNAIL);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -20,10 +21,79 @@ public class GetThumbnailEndpointSummary : Summary<GetThumbnailEndpoint, GetThum
Summary = "Retrieves a thumbnail for a specified file.";
Description = "Returns a thumbnail image for the specified file, with the option to specify the quality.";
RequestParam(r => r.Path, "The path of the file for which to get the thumbnail.");
ExampleRequest = new GetThumbnailRequest(
Path: "/media/contributors/s/patrick_stewart.jpg",
Quality: 75
);
RequestParam(r => r.Path, "The path of the file for which to get the thumbnail. Required.");
RequestParam(r => r.Quality, "The quality to use for the thumbnail.");
Response(200, "The thumbnail image for the specified file is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
Response(200, "The thumbnail image for the specified file is returned.", contentType: "image/*",
example: "Binary file content");
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/thumbnails/get-thumbnail"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/thumbnails/get-thumbnail"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/thumbnails/get-thumbnail"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/thumbnails/get-thumbnail",
traceId = "00-9945ec5ab76ade665761d3493dfbafba-7e8bb1005b4ddc50-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/thumbnails/get-thumbnail",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty",
"ImageQaulityMustBeBetweenZeroAndOneHundred"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -38,7 +38,6 @@ public class AddBookEndpoint : BaseEndpoint<AddBookRequest, IResult>
Verbs(Http.POST);
Routes(ApiRoutes.Books.ADD_BOOK);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -3,7 +3,12 @@ using FastEndpoints;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using Lumina.Contracts.DTO.Common;
using Lumina.Domain.Common.Enums.BookLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.DTO.MediaContributors;
using System;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.AddBook;
@@ -22,24 +27,146 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
Summary = "Adds a new book.";
Description = "Creates a new book and returns its details, including the location of the newly created resource.";
RequestParam(r => r.Metadata, "Written content metadata of the book.");
RequestParam(r => r.Metadata!.Title, "The title of the written content.");
RequestParam(r => r.Format, "The format of the book (e.g., Hardcover, Paperback), if applicable.");
RequestParam(r => r.Edition, "The edition of the book, if applicable.");
RequestParam(r => r.VolumeNumber, "The volume or book number in the series, if applicable.");
RequestParam(r => r.Series, "The series name, if the book is part of a series.");
RequestParam(r => r.ASIN, "The ASIN (Amazon Standard Identification Number) of the book, if applicable.");
RequestParam(r => r.GoodreadsId, "The Goodreads ID of the book, if applicable.");
RequestParam(r => r.LCCN, "The Library of Congress Control Number (LCCN) of the book, if applicable.");
RequestParam(r => r.OCLCNumber, "The OCLC Number (WorldCat identifier) of the book, if applicable.");
RequestParam(r => r.OpenLibraryId, "The Open Library ID of the book, if applicable.");
RequestParam(r => r.LibraryThingId, "The LibraryThing ID of the book, if applicable.");
RequestParam(r => r.GoogleBooksId, "The Google Books ID of the book, if applicable.");
RequestParam(r => r.BarnesAndNobleId, "The Barnes & Noble ID of the book, if applicable.");
RequestParam(r => r.AppleBooksId, "The Apple Books ID of the book, if applicable.");
RequestParam(r => r.ISBNs, "The list of ISBN (International Standard Book Number) of the book.");
RequestParam(r => r.Contributors, "The list of media contributors (actors, directors, etc) starring in this book.");
RequestParam(r => r.Ratings, "The list of ratings for this book.");
ExampleRequest = new AddBookRequest(
Metadata: new(
Title: "The Fellowship of the Ring",
OriginalTitle: "The Fellowship of the Ring",
Description: "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.",
ReleaseInfo: new(
OriginalReleaseDate: DateOnly.ParseExact("1954-07-29", "yyyy-MM-dd", null),
OriginalReleaseYear: 1954,
ReReleaseDate: DateOnly.ParseExact("2001-09-06", "yyyy-MM-dd", null),
ReReleaseYear: 2001,
ReleaseCountry: "uk",
ReleaseVersion: "50th Anniversary Edition"
),
Genres: new List<GenreDto>() {
{ new(Name: "fantasy") },
{ new(Name: "adventure") },
{ new(Name: "classic") }
},
Tags: new List<TagDto>() {
{ new(Name: "epic fantasy") },
{ new(Name: "quest") },
{ new(Name: "middle-earth") }
},
Language: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
OriginalLanguage: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
Publisher: "Houghton Mifflin",
PageCount: 398
),
Format: BookFormat.Paperback,
Edition: "50th Anniversary Edition",
VolumeNumber: 1,
Series: new BookSeriesDto(
Title: "The Lord of the Rings"
),
ASIN: "B007978NPG",
GoodreadsId: "3",
LCCN: "54009621",
OCLCNumber: "ocm00012345",
OpenLibraryId: "OL7603910M",
LibraryThingId: "3203347",
GoogleBooksId: "aWZzLPhY4o0C",
BarnesAndNobleId: "1100307790",
AppleBooksId: "id395211",
ISBNs: [
new(
Value: "0395272238",
Format: IsbnFormat.Isbn10
),
new(
Value: "9780395272237",
Format: IsbnFormat.Isbn13
)
],
Contributors: [
new(
Name: new MediaContributorNameDto(
DisplayName: "J.R.R. Tolkien",
LegalName: "John Ronald Reuel Tolkien"
),
Role: new MediaContributorRoleDto(
Name: "author",
Category: "book"
)
),
new(
Name: new MediaContributorNameDto(
DisplayName: "Alan Lee",
LegalName: "Alan Lee"
),
Role: new MediaContributorRoleDto(
Name: "illustrator",
Category: "book"
)
)
],
Ratings: [
new(
Source: BookRatingSource.GoogleBooks,
Value: 4.36M,
MaxValue: 5,
VoteCount: 2345678
),
new(
Source: BookRatingSource.Amazon,
Value: 4.7M,
MaxValue: 5,
VoteCount: 87654
)
]
);
RequestParam(r => r.Metadata, "Written content metadata of the book. Required.");
RequestParam(r => r.Metadata!.Title, "The title of the written content. Required.");
RequestParam(r => r.Metadata!.OriginalTitle, "The original title of the written content, if different from the current title. Optional.");
RequestParam(r => r.Metadata!.Description, "A brief description or summary of the written content. Optional.");
RequestParam(r => r.Metadata!.ReleaseInfo, "The release information, including release date and other relevant details. Required.");
RequestParam(r => r.Metadata!.ReleaseInfo!.OriginalReleaseDate, "The original release date of the content. Optional.");
RequestParam(r => r.Metadata!.ReleaseInfo!.OriginalReleaseYear, "The original release year of the content. Optional.");
RequestParam(r => r.Metadata!.ReleaseInfo!.ReReleaseDate, "The re-release date of the content. Optional.");
RequestParam(r => r.Metadata!.ReleaseInfo!.ReReleaseYear, "The re-release year of the content. Optional.");
RequestParam(r => r.Metadata!.ReleaseInfo!.ReleaseCountry, "The country where the content was released. Optional.");
RequestParam(r => r.Metadata!.ReleaseInfo!.ReleaseVersion, "The version or edition of the content's release. Optional.");
RequestParam(r => r.Metadata!.Language, "The language in which the written content is written. Optional.");
RequestParam(r => r.Metadata!.Language!.LanguageCode, "The ISO code of the language (e.g., \"en\" for English). Required.");
RequestParam(r => r.Metadata!.Language!.LanguageName, "The name of the language in English. Required.");
RequestParam(r => r.Metadata!.Language!.NativeName, "The native name of the language (e.g., \"Español\" for Spanish). Optional.");
RequestParam(r => r.Metadata!.OriginalLanguage, "The original language in which the written content is written. Optional.");
RequestParam(r => r.Metadata!.OriginalLanguage!.LanguageCode, "The ISO code of the language (e.g., \"en\" for English). Required.");
RequestParam(r => r.Metadata!.OriginalLanguage!.LanguageName, "The name of the language in English. Required.");
RequestParam(r => r.Metadata!.OriginalLanguage!.NativeName, "The native name of the language (e.g., \"Español\" for Spanish). Optional.");
RequestParam(r => r.Metadata!.Tags, "The list of tags that further describe or categorize the written content. Required.");
RequestParam(r => r.Metadata!.Genres, "The list of genres associated with the written content. Required.");
RequestParam(r => r.Metadata!.Publisher, "The name of the publisher of the written content. Optional.");
RequestParam(r => r.Metadata!.PageCount, "The number of pages in the written content. Optional.");
RequestParam(r => r.Format, "The format of the book (e.g., Hardcover, Paperback). Optional.");
RequestParam(r => r.Edition, "The edition of the book. Optional.");
RequestParam(r => r.VolumeNumber, "The volume or book number in the series. Optional.");
RequestParam(r => r.Series, "The series name, if the book is part of a series. Optional.");
RequestParam(r => r.Series!.Title, "The title of the book series. Required.");
RequestParam(r => r.ASIN, "The ASIN (Amazon Standard Identification Number) of the book. Optional.");
RequestParam(r => r.GoodreadsId, "The Goodreads Id of the book. Optional.");
RequestParam(r => r.LCCN, "The Library of Congress Control Number (LCCN) of the book. Optional.");
RequestParam(r => r.OCLCNumber, "The OCLC Number (WorldCat identifier) of the book. Optional.");
RequestParam(r => r.OpenLibraryId, "The Open Library Id of the book. Optional.");
RequestParam(r => r.LibraryThingId, "The LibraryThing Id of the book. Optional.");
RequestParam(r => r.GoogleBooksId, "The Google Books Id of the book. Optional.");
RequestParam(r => r.BarnesAndNobleId, "The Barnes & Noble Id of the book. Optional.");
RequestParam(r => r.AppleBooksId, "The Apple Books Id of the book. Optional.");
RequestParam(r => r.ISBNs, "The list of ISBN (International Standard Book Number) of the book. Required.");
RequestParam(r => r.Contributors, "The list of media contributors (actors, directors, etc) starring in this book. Required.");
RequestParam(r => r.Ratings, "The list of ratings for this book. Required.");
ResponseParam<BookResponse>(r => r.Id, "The unique identifier of the entity.");
ResponseParam<BookResponse>(r => r.Created, "The date and time when the entity was created.");
@@ -47,7 +174,226 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
ResponseParam<BookResponse>(r => r.Metadata, "The written content metadata of the book.");
ResponseParam<BookResponse>(r => r.Metadata.Title, "The title of the media item.");
ResponseParam<BookResponse>(r => r.Metadata.OriginalTitle, "The original title of the media item.");
Response<BookResponse>(201, "The book was successfully created.", "The location of the created resource is provided in the Location header.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
// TODO: continue response params
Response(201, "The new book is returned.", example:
new BookResponse(
Id: Guid.NewGuid(),
Metadata: new(
Title: "The Fellowship of the Ring",
OriginalTitle: "The Fellowship of the Ring",
Description: "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.",
ReleaseInfo: new(
OriginalReleaseDate: DateOnly.ParseExact("1954-07-29", "yyyy-MM-dd", null),
OriginalReleaseYear: 1954,
ReReleaseDate: DateOnly.ParseExact("2001-09-06", "yyyy-MM-dd", null),
ReReleaseYear: 2001,
ReleaseCountry: "uk",
ReleaseVersion: "50th Anniversary Edition"
),
Genres: new List<GenreDto>() {
{ new(Name: "fantasy") },
{ new(Name: "adventure") },
{ new(Name: "classic") }
},
Tags: new List<TagDto>() {
{ new(Name: "epic fantasy") },
{ new(Name: "quest") },
{ new(Name: "middle-earth") }
},
Language: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
OriginalLanguage: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
Publisher: "Houghton Mifflin",
PageCount: 398
),
Format: BookFormat.Paperback,
Edition: "50th Anniversary Edition",
VolumeNumber: 1,
Series: new BookSeriesDto(
Title: "The Lord of the Rings"
),
ASIN: "B007978NPG",
GoodreadsId: "3",
LCCN: "54009621",
OCLCNumber: "ocm00012345",
OpenLibraryId: "OL7603910M",
LibraryThingId: "3203347",
GoogleBooksId: "aWZzLPhY4o0C",
BarnesAndNobleId: "1100307790",
AppleBooksId: "id395211",
ISBNs: [
new(
Value: "0395272238",
Format: IsbnFormat.Isbn10
),
new(
Value: "9780395272237",
Format: IsbnFormat.Isbn13
)
],
Contributors: [
new(
Name: new MediaContributorNameDto(
DisplayName: "J.R.R. Tolkien",
LegalName: "John Ronald Reuel Tolkien"
),
Role: new MediaContributorRoleDto(
Name: "author",
Category: "book"
)
),
new(
Name: new MediaContributorNameDto(
DisplayName: "Alan Lee",
LegalName: "Alan Lee"
),
Role: new MediaContributorRoleDto(
Name: "illustrator",
Category: "book"
)
)
],
Ratings: [
new(
Source: BookRatingSource.GoogleBooks,
Value: 4.36M,
MaxValue: 5,
VoteCount: 2345678
),
new(
Source: BookRatingSource.Amazon,
Value: 4.7M,
MaxValue: 5,
VoteCount: 87654
)
],
Created: DateTime.UtcNow,
Updated: default
)
);
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/books"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/books"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/books"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/books",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"TitleCannotBeEmpty",
"TitleMustBeMaximum255CharactersLong",
"OriginalTitleMustBeMaximum255CharactersLong",
"DescriptionMustBeMaximum2000CharactersLong",
"ReleaseInfoCannotBeNull",
"OriginalReleaseYearMustBeBetween1And9999",
"ReReleaseYearMustBeBetween1And9999",
"CountryCodeMustBe2CharactersLong",
"ReleaseVersionMustBeMaximum50CharactersLong",
"OriginalReleaseDateAndYearMustMatch",
"ReReleaseDateAndYearMustMatch",
"ReReleaseYearCannotBeEarlierThanOriginalReleaseYear",
"ReReleaseDateCannotBeEarlierThanOriginalReleaseDate",
"ReReleaseDateAndYearMustMatch",
"GenresListCannotBeNull",
"GenreNameCannotBeEmpty",
"GenreNameMustBeMaximum50CharactersLong",
"TagsListCannotBeNull",
"TagNameCannotBeEmpty",
"TagNameMustBeMaximum50CharactersLong",
"LanguageCodeCannotBeEmpty",
"LanguageCodeMustBe2CharactersLong",
"LanguageNameCannotBeEmpty",
"LanguageNameMustBeMaximum50CharactersLong",
"LanguageNativeNameMustBeMaximum50CharactersLong",
"PublisherMustBeMaximum100CharactersLong",
"UnknownBookFormat",
"PageCountMustBeGreaterThanZero",
"UnknownBookFormat",
"EditionMustBeMaximum50CharactersLong",
"VolumeNumberMustBeGreaterThanZero",
"TitleCannotBeEmpty",
"TitleMustBeMaximum255CharactersLong",
"AsinMustBe10CharactersLong",
"GoodreadsIdMustBeNumeric",
"InvalidLccnFormat",
"InvalidOclcFormat",
"InvalidOpenLibraryId",
"LibraryThingIdMustBeMaximum50CharactersLong",
"GoogleBooksIdMustBe12CharactersLong",
"InvalidGoogleBooksIdFormat",
"BarnesAndNoblesIdMustBe10CharactersLong",
"InvalidBarnesAndNoblesIdFormat",
"InvalidAppleBooksIdFormat",
"IsbnListCannotBeNull",
"IsbnValueCannotBeEmpty",
"InvalidIsbn13Format",
"InvalidIsbn10Format",
"UnknownIsbnFormat",
"ContributorsListCannotBeNull",
"ContributorNameCannotBeEmpty",
"ContributorDisplayNameCannotBeEmpty",
"ContributorDisplayNameMustBeMaximum100CharactersLong",
"ContributorLegalNameMustBeMaximum100CharactersLong",
"ContributorRoleCannotBeNull",
"RoleNameCannotBeEmpty",
"RoleNameMustBeMaximum50CharactersLong",
"RoleCategoryCannotBeEmpty",
"RoleCategoryMustBeMaximum50CharactersLong",
"RatingsListCannotBeNull",
"RatingValueMustBePositive",
"RatingValueCannotBeGreaterThanMaxValue",
"RatingMaxValueMustBePositive",
"RatingVoteCountMustBePositive"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -38,7 +38,6 @@ public class GetBooksEndpoint : BaseEndpoint<EmptyRequest, IResult>
Verbs(Http.GET);
Routes(ApiRoutes.Books.GET_BOOKS);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -1,6 +1,11 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -21,6 +26,245 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
Summary = "Retrieves the list of books.";
Description = "Returns the entire list of books.";
Response<IEnumerable<BookResponse>>(200, "The list of books is returned.");
Response(200, "The list of books is returned.",
example: new BookResponse[] {
new(
Id: Guid.NewGuid(),
Metadata: new(
Title: "The Fellowship of the Ring",
OriginalTitle: "The Fellowship of the Ring",
Description: "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.",
ReleaseInfo: new(
OriginalReleaseDate: DateOnly.ParseExact("1954-07-29", "yyyy-MM-dd", null),
OriginalReleaseYear: 1954,
ReReleaseDate: DateOnly.ParseExact("2001-09-06", "yyyy-MM-dd", null),
ReReleaseYear: 2001,
ReleaseCountry: "uk",
ReleaseVersion: "50th Anniversary Edition"
),
Genres: new List<GenreDto>() {
{ new(Name: "fantasy") },
{ new(Name: "adventure") },
{ new(Name: "classic") }
},
Tags: new List<TagDto>() {
{ new(Name: "epic fantasy") },
{ new(Name: "quest") },
{ new(Name: "middle-earth") }
},
Language: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
OriginalLanguage: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
Publisher: "Houghton Mifflin",
PageCount: 398
),
Format: BookFormat.Paperback,
Edition: "50th Anniversary Edition",
VolumeNumber: 1,
Series: new BookSeriesDto(
Title: "The Lord of the Rings"
),
ASIN: "B007978NPG",
GoodreadsId: "3",
LCCN: "54009621",
OCLCNumber: "ocm00012345",
OpenLibraryId: "OL7603910M",
LibraryThingId: "3203347",
GoogleBooksId: "aWZzLPhY4o0C",
BarnesAndNobleId: "1100307790",
AppleBooksId: "id395211",
ISBNs: [
new(
Value: "0395272238",
Format: IsbnFormat.Isbn10
),
new(
Value: "9780395272237",
Format: IsbnFormat.Isbn13
)
],
Contributors: [
new(
Name: new MediaContributorNameDto(
DisplayName: "J.R.R. Tolkien",
LegalName: "John Ronald Reuel Tolkien"
),
Role: new MediaContributorRoleDto(
Name: "author",
Category: "book"
)
),
new(
Name: new MediaContributorNameDto(
DisplayName: "Alan Lee",
LegalName: "Alan Lee"
),
Role: new MediaContributorRoleDto(
Name: "illustrator",
Category: "book"
)
)
],
Ratings: [
new(
Source: BookRatingSource.GoogleBooks,
Value: 4.36M,
MaxValue: 5,
VoteCount: 2345678
),
new(
Source: BookRatingSource.Amazon,
Value: 4.7M,
MaxValue: 5,
VoteCount: 87654
)
],
Created: DateTime.UtcNow,
Updated: default
),
new(
Id: Guid.NewGuid(),
Metadata: new(
Title: "The Two Towers",
OriginalTitle: "The Two Towers",
Description: "The second part of J.R.R. Tolkien's epic adventure The Lord of the Rings. The Fellowship is scattered, and the quest to destroy the One Ring continues. Aragorn, Legolas, and Gimli search for Merry and Pippin, while Frodo and Sam take the Ring closer to Mordor under the guidance of the mysterious Gollum.",
ReleaseInfo: new(
OriginalReleaseDate: DateOnly.ParseExact("1954-11-11", "yyyy-MM-dd", null),
OriginalReleaseYear: 1954,
ReReleaseDate: DateOnly.ParseExact("2001-11-08", "yyyy-MM-dd", null),
ReReleaseYear: 2001,
ReleaseCountry: "uk",
ReleaseVersion: "50th Anniversary Edition"
),
Genres: new List<GenreDto>() {
{ new(Name: "fantasy") },
{ new(Name: "adventure") },
{ new(Name: "classic") }
},
Tags: new List<TagDto>() {
{ new(Name: "epic fantasy") },
{ new(Name: "quest") },
{ new(Name: "middle-earth") }
},
Language: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
OriginalLanguage: new(
LanguageCode: "en",
LanguageName: "English",
NativeName: "English"
),
Publisher: "Houghton Mifflin",
PageCount: 352
),
Format: BookFormat.Hardcover,
Edition: "50th Anniversary Edition",
VolumeNumber: 2,
Series: new BookSeriesDto(
Title: "The Lord of the Rings"
),
ASIN: "B007978NPZ",
GoodreadsId: "33",
LCCN: "54009622",
OCLCNumber: "ocm00067890",
OpenLibraryId: "OL7603911M",
LibraryThingId: "3203348",
GoogleBooksId: "aWZzLPhY4o1D",
BarnesAndNobleId: "1100307791",
AppleBooksId: "id395212",
ISBNs: [
new(
Value: "0395272246",
Format: IsbnFormat.Isbn10
),
new(
Value: "9780395272244",
Format: IsbnFormat.Isbn13
)
],
Contributors: [
new(
Name: new MediaContributorNameDto(
DisplayName: "J.R.R. Tolkien",
LegalName: "John Ronald Reuel Tolkien"
),
Role: new MediaContributorRoleDto(
Name: "author",
Category: "book"
)
),
new(
Name: new MediaContributorNameDto(
DisplayName: "Alan Lee",
LegalName: "Alan Lee"
),
Role: new MediaContributorRoleDto(
Name: "illustrator",
Category: "book"
)
)
],
Ratings: [
new(
Source: BookRatingSource.GoogleBooks,
Value: 4.4M,
MaxValue: 5,
VoteCount: 2340000
),
new(
Source: BookRatingSource.Amazon,
Value: 4.8M,
MaxValue: 5,
VoteCount: 90000
)
],
Created: DateTime.UtcNow,
Updated: default
)
}
);
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/books"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/books"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/books"
}
}
);
}
}
@@ -38,7 +38,6 @@ public class AddLibraryEndpoint : BaseEndpoint<AddLibraryRequest, IResult>
Verbs(Http.POST);
Routes(ApiRoutes.Libraries.ADD_LIBRARY);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -2,6 +2,9 @@
using FastEndpoints;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -23,10 +26,20 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
Summary = "Adds a new media library.";
Description = "Creates a new media library and returns its details, including the location of the newly created resource.";
RequestParam(r => r.UserId, "The Id of the user owning the media library.");
RequestParam(r => r.Title, "The title of the media library.");
RequestParam(r => r.LibraryType, "The type of the media library.");
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located.");
ExampleRequest = new AddLibraryRequest(
UserId: Guid.NewGuid(),
Title: "TV Shows",
LibraryType: LibraryType.TvShow,
ContentLocations: [
"/media/tv shows/drama/",
"/media/tv shows/SCI-FI/",
]
);
RequestParam(r => r.UserId, "The Id of the user owning the media library. Required.");
RequestParam(r => r.Title, "The title of the media library. Required.");
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required.");
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
@@ -35,7 +48,76 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
ResponseParam<LibraryResponse>(r => r.Created, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.Updated, "The date and time when the entity was last updated.");
Response<LibraryResponse>(201, "The media library was successfully created.", "The location of the created resource is provided in the Location header.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
Response(201, "The media library was successfully created.", example:
new LibraryResponse(
Id: Guid.NewGuid(),
UserId: Guid.NewGuid(),
Title: "TV Shows",
LibraryType: LibraryType.TvShow,
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
Created: DateTime.UtcNow,
Updated: default
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/libraries"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/libraries"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/libraries"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/libraries",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"UserIdCannotBeEmpty",
"LibraryTypeCannotBeNull",
"UnknownLibraryType",
"PathsListCannotBeNull",
"PathsListCannotBeEmpty",
"PathCannotBeEmpty",
"TitleCannotBeEmpty",
"TitleMustBeMaximum255CharactersLong"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
}
}
@@ -20,6 +20,9 @@ public class CheckInitializationEndpointSummary : Summary<CheckInitializationEnd
Summary = "Checks the initialization status of the application.";
Description = "Checks the initialization status of the application (if the Admin account exists).";
Response<InitializationResponse>(200, "The application initialization status is returned.");
Response(200, "The application initialization status is returned.",
example: new InitializationResponse(
IsInitialized: true
));
}
}
@@ -1,6 +1,9 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -20,12 +23,66 @@ public class SetupApplicationEndpointSummary : Summary<SetupApplicationEndpoint,
Summary = "Performs the initial application setup.";
Description = "Performs the initial application setup, including creating the Admin account.";
RequestParam(r => r.Username, "The desired username for the new account.");
RequestParam(r => r.Password, "The password for the new account.");
RequestParam(r => r.PasswordConfirm, "The confirmation of the entered password, used to ensure consistency.");
RequestParam(r => r.Use2fa, "Indicates whether two-factor authentication (2FA) should be enabled for the new account.");
ExampleRequest = new RegistrationRequest(
Username: "JohnDoe",
Password: "Abcd123$",
PasswordConfirm: "Abcd123$",
Use2fa: true
);
RequestExamples.Add(new RequestExample(new RegistrationRequest(
Username: "JohnDoe",
Password: "Abcd123$",
PasswordConfirm: "Abcd123$",
Use2fa: false
)));
Response(200, "The Admin account of the application is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Username, "The desired username for the new account. Required.");
RequestParam(r => r.Password, "The password for the new account. Required.");
RequestParam(r => r.PasswordConfirm, "The confirmation of the entered password, used to ensure consistency. Required.");
RequestParam(r => r.Use2fa, "Indicates whether two-factor authentication (2FA) should be enabled for the new account. Optional.");
Response(201, "The Admin account of the application is returned.", example:
new RegistrationResponse(
Id: Guid.NewGuid(),
Username: "JohnDoe",
TotpSecret: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABCQAAAQkAQAAAACN7fKkAAAFW0lEQVR4nO3bQW4cOQwF0L6B73/L3MABjCp/ilR1BphkFAl..."
));
Response(403, "The request failed because the application is already initialized (Admin account exists).", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Unauthorized",
status = 403,
detail = "AdminAccountAlreadyCreated",
instance = "/api/v1/initialization",
traceId = "00-4d94289ee3cddd8d1a3da9ef35bd37a8-585fbdf2b5ad5e03-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/initialization",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"UsernameCannotBeEmpty",
"PassordCannotBeEmpty",
"InvalidPassword",
"PasswordConfirmCannotBeEmpty",
"PasswordsNotMatch"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
}
}
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -18,13 +20,103 @@ public class ChangePasswordEndpointSummary : Summary<ChangePasswordEndpoint, Cha
public ChangePasswordEndpointSummary()
{
Summary = "Changes the password of an account.";
Description = "Changes the password of an account by reseting its password, after verifying TOTP code associated with the account.";
Description = "Changes the password of an account.";
RequestParam(r => r.CurrentPassword, "The current password of the account for which to change the password.");
RequestParam(r => r.NewPassword, "The new password of the account for which to change the password.");
RequestParam(r => r.NewPasswordConfirm, "The confirmation of the new password of the account for which to change the password.");
ExampleRequest = new ChangePasswordRequest(
Username: "JohnDoe",
CurrentPassword: "Abcd123$",
NewPassword: "123$Abcd",
NewPasswordConfirm: "123$Abcd"
);
Response(200, "The password of the account is changed.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Username, "The username of the account. Required.");
RequestParam(r => r.CurrentPassword, "The current password of the account for which to change the password. Required.");
RequestParam(r => r.NewPassword, "The new password of the account for which to change the password. Required.");
RequestParam(r => r.NewPasswordConfirm, "The confirmation of the new password of the account for which to change the password. Required.");
Response(200, "The password of the account is changed.",
example: new ChangePasswordResponse(
IsPasswordChanged: true
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/auth/change-password"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/auth/change-password"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/auth/change-password"
}
}
);
Response(403, "The request failed because the current password is invalid.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "InvalidCurrentPassword",
instance = "/api/v1/auth/change-password",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(404, "The request failed because the provided username does not exist.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
title = "General.NotFound",
status = 404,
detail = "UsernameDoesNotExist",
instance = "/api/v1/auth/change-password",
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/auth/change-password",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"UsernameCannotBeEmpty",
"CurrentPasswordCannotBeEmpty",
"NewPasswordCannotBeEmpty",
"NewPasswordConfirmCannotBeEmpty",
"InvalidPassword",
"PasswordsNotMatch"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -1,6 +1,9 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -20,11 +23,72 @@ public class LoginEndpointSummary : Summary<LoginEndpoint, LoginRequest>
Summary = "Authenticates an account.";
Description = "Authenticates an application account.";
RequestParam(r => r.Username, "The username of the account to authenticate.");
RequestParam(r => r.Password, "The password of the account to authenticate.");
RequestParam(r => r.TotpCode, "The TOTP (Time-Based One-Time Password) of the account to authenticate.");
ExampleRequest = new LoginRequest(
Username: "JohnDoe",
Password: "Abcd123$",
TotpCode: "123456"
);
RequestExamples.Add(new RequestExample(new LoginRequest(
Username: "JohnDoe",
Password: "Abcd123$"
)));
RequestParam(r => r.Username, "The username of the account to authenticate. Required.");
RequestParam(r => r.Password, "The password of the account to authenticate. Required.");
RequestParam(r => r.TotpCode, "The TOTP (Time-Based One-Time Password) of the account to authenticate. Optional.");
Response(200, "The JWT authentication token is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
Response(200, "The JWT authentication token is returned.",
example: new LoginResponse(
Guid.NewGuid(),
Username: "JohnDoe",
Token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwNzE2Y2E1ZC1hZjhkLT...",
UsesTotp: true
));
Response(403, "For regular login, the request failed because a either the username or the password is invalid. For password recovery, this is returned when the temporary password used to login expires (more than 15 minutes passed since its generation).", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "InvalidUsernameOrPassword",
instance = "/api/v1/auth/login",
traceId = "00-7abff4d7d261fa2fa503fef236b2a139-2198f929121f0707-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/auth/login",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"UsernameCannotBeEmpty",
"PasswordCannotBeEmpty",
"InvalidPassword",
"InvalidTotpCode"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
title = "TooManyRequests",
status = 429,
detail = "Too many attempts. Please try again later.",
retryAfter = "900"
}
);
}
}
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -20,10 +22,75 @@ public class RecoverPasswordEndpointSummary : Summary<RecoverPasswordEndpoint, R
Summary = "Recovers the password of an account.";
Description = "Recovers the password of an account by reseting its password, after verifying TOTP code associated with the account.";
RequestParam(r => r.Username, "The username of the account for which to recover the password.");
RequestParam(r => r.TotpCode, "The TOTP (Time-Based One-Time Password) of the account for which to recover the password.");
ExampleRequest = new RecoverPasswordRequest(
Username: "JohnDoe",
TotpCode: "123456"
);
Response(200, "The password of the account is reset.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Username, "The username of the account for which to recover the password. Required.");
RequestParam(r => r.TotpCode, "The TOTP (Time-Based One-Time Password) of the account for which to recover the password. Required.");
Response(200, "The password of the account is reset.",
example: new RecoverPasswordResponse(
IsPasswordReset: true
));
Response(403, "The request failed because a password request was already requested and not finalized.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "PasswordResetAlreadyRequested",
instance = "/api/v1/auth/recover-password",
traceId = "00-2ffb801e4762c9d3a5ac1a6d05721e61-7d29fda06ae9b4e2-00"
}
);
Response(404, "The request failed because the provided username does not exist.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
title = "General.NotFound",
status = 404,
detail = "UsernameDoesNotExist",
instance = "/api/v1/auth/recover-password",
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/auth/recover-password",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"UsernameCannotBeEmpty",
"TotpCannotBeEmpty",
"InvalidTotpCode"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
title = "TooManyRequests",
status = 429,
detail = "Too many attempts. Please try again later.",
retryAfter = "900"
}
);
}
}
@@ -1,6 +1,12 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -18,14 +24,81 @@ public class RegisterEndpointSummary : Summary<RegisterEndpoint, RegistrationReq
public RegisterEndpointSummary()
{
Summary = "Registers a new account.";
Description = "Registes a new application account.";
Description = "Registers a new application account.";
RequestParam(r => r.Username, "The desired username for the new account.");
RequestParam(r => r.Password, "The password for the new account.");
RequestParam(r => r.PasswordConfirm, "The confirmation of the entered password, used to ensure consistency.");
RequestParam(r => r.Use2fa, "Indicates whether two-factor authentication (2FA) should be enabled for the new account.");
ExampleRequest = new RegistrationRequest(
Username: "JohnDoe",
Password: "Abcd123$",
PasswordConfirm: "Abcd123$",
Use2fa: true
);
RequestExamples.Add(new RequestExample(new RegistrationRequest(
Username: "JohnDoe",
Password: "Abcd123$",
PasswordConfirm: "Abcd123$",
Use2fa: false
)));
Response(200, "The new account of the application is returned.");
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
RequestParam(r => r.Username, "The desired username for the new account. Required.");
RequestParam(r => r.Password, "The password for the new account. Required.");
RequestParam(r => r.PasswordConfirm, "The confirmation of the entered password, used to ensure consistency. Required.");
RequestParam(r => r.Use2fa, "Indicates whether two-factor authentication (2FA) should be enabled for the new account. Optional.");
Response(201, "The new account is returned.", example:
new RegistrationResponse(
Id: Guid.NewGuid(),
Username: "JohnDoe",
TotpSecret: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABCQAAAQkAQAAAACN7fKkAAAFW0lEQVR4nO3bQW4cOQwF0L6B73/L3MABjCp/ilR1BphkFAl..."
));
Response(409, "The request failed due to a conflict, username already exists.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.10",
title = "General.Conflict",
status = 409,
detail = "UsernameAlreadyExists",
instance = "/api/v1/auth/register",
traceId = "00-f8784de7cb2d70b81b2529893068bee7-4779e0404fe5f554-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/auth/register",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"UsernameCannotBeEmpty",
"PassordCannotBeEmpty",
"UsernameMustBeBetween3And255CharactersLong",
"InvalidUsername",
"InvalidPassword",
"PasswordConfirmCannotBeEmpty",
"PasswordsNotMatch"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
title = "TooManyRequests",
status = 429,
detail = "Too many attempts. Please try again later.",
retryAfter = "900"
}
);
}
}
@@ -64,7 +64,7 @@
<div class="form-row">
<div class="form-field">
<label class="enlightenment-checkbox-label">
<input type="checkbox" asp-for="Use2fa" class="enlightenment-checkbox-hidden" value="true" />
<input type="checkbox" asp-for="Use2fa" class="enlightenment-checkbox-hidden" value="true" checked/>
<span class="enlightenment-checkbox"></span>
Enable two factor authentication
</label>
@@ -86,7 +86,7 @@
<p id="totp-message" class="text-light-one w-100 hidden">Scan Totp Code</p>
@if (User?.Identity?.IsAuthenticated == false)
{
<button id="btn-login" type="button" class="confirm-button h-22px w-80px mx-auto mt-10 hidden" data-link="@_urlService.GetAbsoluteUrl("Login", "Auth")">Login</button>
<button id="btn-login" type="button" class="confirm-button h-22px w-80px mx-auto mt-10 hidden">Login</button>
}
</div>
</div>
@@ -136,5 +136,8 @@
);
document.getElementById('#hidden-use-two-fa').value = isChecked.toString();
});
document.getElementById('btn-login').addEventListener('click', () => {
window.location.href = '@_urlService.GetAbsoluteUrl("Login", "Auth")';
});
</script>
}