From 77f95708b9acf0f1f1c4135fcd5e051d3366e6b7 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Fri, 15 Nov 2024 21:01:19 +0200 Subject: [PATCH 1/2] Improves OpenApi documentation --- .../CheckPathExists/CheckPathExistsQuery.cs | 3 +- .../CheckPathExistsQueryHandler.cs | 9 +- .../DTO/Common/LanguageInfoDto.cs | 6 +- .../DTO/Common/ReleaseInfoDto.cs | 12 +- .../WrittenContentMetadataDto.cs | 20 +- src/Lumina.Contracts/Lumina.Contracts.csproj | 4 + .../Authentication/ChangePasswordRequest.cs | 8 +- .../Requests/Authentication/LoginRequest.cs | 6 +- .../Authentication/RecoverPasswordRequest.cs | 4 +- .../Authentication/RegistrationRequest.cs | 8 +- .../Directories/GetDirectoriesRequest.cs | 4 +- .../Directories/GetDirectoryTreeRequest.cs | 6 +- .../Directories/GetTreeDirectoriesRequest.cs | 4 +- .../Files/GetFilesRequest.cs | 4 +- .../Files/GetTreeFilesRequest.cs | 4 +- .../Path/CheckPathExistsRequest.cs | 4 +- .../Path/CombinePathRequest.cs | 5 +- .../Path/GetPathParentRequest.cs | 2 +- .../Path/GetPathRootRequest.cs | 2 +- .../Path/SplitPathRequest.cs | 2 +- .../Path/ValidatePathRequest.cs | 2 +- .../Thumbnails/GetThumbnailRequest.cs | 1 - .../Management/AddLibraryRequest.cs | 8 +- .../BookLibrary/Books/AddBookRequest.cs | 34 +- .../PresentationApiLayerServices.cs | 29 +- .../Core/Endpoints/Common/BaseEndpoint.cs | 4 +- .../GetDirectories/GetDirectoriesEndpoint.cs | 1 - .../GetDirectoriesEndpointSummary.cs | 84 +++- .../GetDirectoryTreeEndpoint.cs | 1 - .../GetDirectoryTreeEndpointSummary.cs | 167 +++++++- .../GetTreeDirectoriesEndpoint.cs | 1 - .../GetTreeDirectoriesEndpointSummary.cs | 84 +++- .../Drives/GetDrives/GetDrivesEndpoint.cs | 1 - .../GetDrives/GetDrivesEndpointSummary.cs | 38 +- .../FileSystem/GetType/GetTypeEndpoint.cs | 1 - .../GetType/GetTypeEndpointSummary.cs | 38 +- .../Files/GetFiles/GetFilesEndpoint.cs | 1 - .../Files/GetFiles/GetFilesEndpointSummary.cs | 85 +++- .../GetTreeFiles/GetTreeFilesEndpoint.cs | 1 - .../GetTreeFilesEndpointSummary.cs | 85 +++- .../CheckPathExistsEndpoint.cs | 6 +- .../CheckPathExistsEndpointSummary.cs | 71 +++- .../Path/CombinePath/CombinePathEndpoint.cs | 1 - .../CombinePath/CombinePathEndpointSummary.cs | 67 ++- .../GetPathParent/GetPathParentEndpoint.cs | 1 - .../GetPathParentEndpointSummary.cs | 76 +++- .../Path/GetPathRoot/GetPathRootEndpoint.cs | 1 - .../GetPathRoot/GetPathRootEndpointSummary.cs | 68 ++- .../GetPathSeparatorEndpoint.cs | 1 - .../GetPathSeparatorEndpointSummary.cs | 35 +- .../Path/SplitPath/SplitPathEndpoint.cs | 1 - .../SplitPath/SplitPathEndpointSummary.cs | 65 ++- .../Path/ValidatePath/ValidatePathEndpoint.cs | 1 - .../ValidatePathEndpointSummary.cs | 64 ++- .../GetThumbnail/GetThumbnailEndpoint.cs | 1 - .../GetThumbnailEndpointSummary.cs | 76 +++- .../Books/AddBook/AddBookEndpoint.cs | 1 - .../Books/AddBook/AddBookEndpointSummary.cs | 388 +++++++++++++++++- .../Books/GetBooks/GetBooksEndpoint.cs | 1 - .../Books/GetBooks/GetBooksEndpointSummary.cs | 246 ++++++++++- .../AddLibrary/AddLibraryEndpoint.cs | 1 - .../AddLibrary/AddLibraryEndpointSummary.cs | 94 ++++- .../CheckInitializationEndpointSummary.cs | 5 +- .../SetupApplicationEndpointSummary.cs | 69 +++- .../ChangePasswordEndpointSummary.cs | 104 ++++- .../Login/LoginEndpointSummary.cs | 74 +++- .../RecoverPasswordEndpointSummary.cs | 75 +++- .../Register/RegisterEndpointSummary.cs | 87 +++- .../Views/Auth/Register.cshtml | 7 +- .../GetDirectoriesEndpointTests.cs | 4 +- .../GetDirectoryTreeEndpointTests.cs | 8 +- .../GetTreeDirectoriesEndpointTests.cs | 4 +- .../Files/GetFilesEndpointTests.cs | 4 +- .../Files/GetTreeFilesEndpointTests.cs | 4 +- .../Path/CombinePathEndpointTests.cs | 4 +- .../Path/GetPathParentEndpointTests.cs | 8 +- .../Path/GetPathRootEndpointTests.cs | 8 +- .../Path/SplitPathEndpointTests.cs | 8 +- .../Thumbnails/GetThumbnailEndpointTests.cs | 8 +- .../ChangePasswordEndpointTests.cs | 8 +- .../Authentication/LoginEndpointTests.cs | 4 +- .../RecoverPasswordEndpointTests.cs | 16 +- .../BookLibrary/Books/AddBookEndpointTests.cs | 4 +- .../Authentication/AuthLoginTests.cs | 2 +- .../AuthRecoverPasswordTests.cs | 2 +- .../Authentication/AuthRegisterTests.cs | 2 +- .../Endpoints/Common/BaseEndpointTests.cs | 12 +- .../GetDirectoriesEndpointTests.cs | 4 +- .../GetDirectoryTreeEndpointTests.cs | 4 +- .../GetTreeDirectoriesEndpointTests.cs | 4 +- .../Files/GetFilesEndpointTests.cs | 4 +- .../Files/GetTreeFilesEndpointTests.cs | 4 +- .../Path/CombinePathEndpointTests.cs | 4 +- .../Path/GetPathParentEndpointTests.cs | 4 +- .../Path/GetPathRootEndpointTests.cs | 4 +- .../Path/SplitPathEndpointTests.cs | 4 +- .../Thumbnails/GetThumbnailEndpointTests.cs | 4 +- .../ChangePasswordEndpointTests.cs | 2 +- .../Login/LoginEndpointTests.cs | 2 +- .../RecoverPasswordEndpointTests.cs | 2 +- .../Register/RegisterEndpointTests.cs | 4 +- 101 files changed, 2336 insertions(+), 294 deletions(-) diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs index 13cbfbb5..30ef5ff9 100644 --- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs +++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQuery.cs @@ -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; +) : IRequest>; diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryHandler.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryHandler.cs index 7004ac97..df02b2eb 100644 --- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryHandler.cs +++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryHandler.cs @@ -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 /// /// Handler for the query to check the existence a file system path. /// -public class CheckPathExistsQueryHandler : IRequestHandler +public class CheckPathExistsQueryHandler : IRequestHandler> { private readonly IPathService _pathService; @@ -30,10 +31,10 @@ public class CheckPathExistsQueryHandler : IRequestHandlerThe query containing the request. /// Cancellation token that can be used to stop the execution. /// - /// if the specified path exists, otherwise. + /// An containing either if the specified path exists, if it doesn't, or an error message. /// - public ValueTask Handle(CheckPathExistsQuery request, CancellationToken cancellationToken) + public ValueTask> 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)))); } } diff --git a/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs b/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs index 173443c9..a3db4e05 100644 --- a/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs +++ b/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs @@ -7,9 +7,9 @@ namespace Lumina.Contracts.DTO.Common; /// /// Data transfer object for language information. /// -/// Gets the ISO code of the language (e.g., "en" for English). -/// Gets the name of the language in English. -/// Gets the native name of the language (e.g., "Español" for Spanish). +/// Gets the ISO code of the language (e.g., "en" for English). Required. +/// Gets the name of the language in English. Required. +/// Gets the native name of the language (e.g., "Español" for Spanish). Optional. [DebuggerDisplay("LanguageName: {LanguageName}")] public record LanguageInfoDto( string? LanguageCode, diff --git a/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs b/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs index 89c4b203..34b314b0 100644 --- a/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs +++ b/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs @@ -8,12 +8,12 @@ namespace Lumina.Contracts.DTO.Common; /// /// Data transfer object for a release information. /// -/// Gets the original release date of the content. -/// Gets the original release year of the content. -/// Gets the re-release date of the content, if applicable. -/// Gets the re-release year of the content, if applicable. -/// Gets the country where the content was released. -/// Gets the version or edition of the content's release. +/// Gets the original release date of the content. Optional. +/// Gets the original release year of the content. Optional. +/// Gets the re-release date of the content. Optional. +/// Gets the re-release year of the content. Optional. +/// Gets the country where the content was released. Optional. +/// Gets the version or edition of the content's release. Optional. [DebuggerDisplay("OriginalReleaseDate: {OriginalReleaseDate}")] public record ReleaseInfoDto( DateOnly? OriginalReleaseDate, diff --git a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDto.cs b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDto.cs index 84099eb8..31fd60e5 100644 --- a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDto.cs +++ b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDto.cs @@ -9,16 +9,16 @@ namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary; /// /// Data transfer object for written content metadata. /// -/// The title of the written content. -/// The original title of the written content, if different from the current title. -/// Gets a brief description or summary of the written content. -/// The release information, including release date and other relevant details. -/// The list of genres associated with the written content. -/// The list of tags that further describe or categorize the written content. -/// The language in which the written content is written. -/// The original language of the written content, if it has been translated. -/// The name of the publisher of the written content. -/// The number of pages in the written content. +/// The title of the written content. Required. +/// The original title of the written content, if different from the current title. Optional. +/// Gets a brief description or summary of the written content. Optional. +/// The release information, including release date and other relevant details. Required. +/// The list of genres associated with the written content. Required. +/// The list of tags that further describe or categorize the written content. Required. +/// The language in which the written content is written. Optional. +/// The original language of the written content, if it has been translated. Optional. +/// The name of the publisher of the written content. Optional. +/// The number of pages in the written content. Optional. [DebuggerDisplay("Title: {Title}")] public record WrittenContentMetadataDto( string? Title, diff --git a/src/Lumina.Contracts/Lumina.Contracts.csproj b/src/Lumina.Contracts/Lumina.Contracts.csproj index 19cb6d5f..dd396efb 100644 --- a/src/Lumina.Contracts/Lumina.Contracts.csproj +++ b/src/Lumina.Contracts/Lumina.Contracts.csproj @@ -13,6 +13,10 @@ + + + + diff --git a/src/Lumina.Contracts/Requests/Authentication/ChangePasswordRequest.cs b/src/Lumina.Contracts/Requests/Authentication/ChangePasswordRequest.cs index 899092c8..0f75f0b3 100644 --- a/src/Lumina.Contracts/Requests/Authentication/ChangePasswordRequest.cs +++ b/src/Lumina.Contracts/Requests/Authentication/ChangePasswordRequest.cs @@ -3,10 +3,10 @@ namespace Lumina.Contracts.Requests.Authentication; /// /// Represents the request model for account password change. /// -/// The username of the account. -/// The current password of the account. -/// The new password of the account. -/// The confirmation of the new password of the account. +/// The username of the account. Required. +/// The current password of the account. Required. +/// The new password of the account. Required. +/// The confirmation of the new password of the account. Required. public record ChangePasswordRequest( string? Username, string? CurrentPassword, diff --git a/src/Lumina.Contracts/Requests/Authentication/LoginRequest.cs b/src/Lumina.Contracts/Requests/Authentication/LoginRequest.cs index ac24be8b..51887f05 100644 --- a/src/Lumina.Contracts/Requests/Authentication/LoginRequest.cs +++ b/src/Lumina.Contracts/Requests/Authentication/LoginRequest.cs @@ -7,9 +7,9 @@ namespace Lumina.Contracts.Requests.Authentication; /// /// Represents the request model for user authentication. /// -/// The username of the account to authenticate. -/// The password of the account to authenticate. -/// The TOTP (Time-Based One-Time Password) of the account to authenticate. +/// The username of the account to authenticate. Required. +/// The password of the account to authenticate. Required. +/// The TOTP (Time-Based One-Time Password) of the account to authenticate. Optional. [DebuggerDisplay("Username: {Username}")] public record LoginRequest( string? Username, diff --git a/src/Lumina.Contracts/Requests/Authentication/RecoverPasswordRequest.cs b/src/Lumina.Contracts/Requests/Authentication/RecoverPasswordRequest.cs index be02df67..1f763aac 100644 --- a/src/Lumina.Contracts/Requests/Authentication/RecoverPasswordRequest.cs +++ b/src/Lumina.Contracts/Requests/Authentication/RecoverPasswordRequest.cs @@ -7,8 +7,8 @@ namespace Lumina.Contracts.Requests.Authentication; /// /// Represents the request model for account password recovery. /// -/// The username of the account for which to recover the password. -/// The TOTP (Time-Based One-Time Password) of the account for which to recover the password. +/// The username of the account for which to recover the password. Required. +/// The TOTP (Time-Based One-Time Password) of the account for which to recover the password. Required. [DebuggerDisplay("Username: {Username}")] public record RecoverPasswordRequest( string? Username, diff --git a/src/Lumina.Contracts/Requests/Authentication/RegistrationRequest.cs b/src/Lumina.Contracts/Requests/Authentication/RegistrationRequest.cs index f30762e4..d1efe817 100644 --- a/src/Lumina.Contracts/Requests/Authentication/RegistrationRequest.cs +++ b/src/Lumina.Contracts/Requests/Authentication/RegistrationRequest.cs @@ -7,10 +7,10 @@ namespace Lumina.Contracts.Requests.Authentication; /// /// Represents the request model for user registration. /// -/// The desired username for the new account. -/// The password for the new account. -/// The confirmation of the entered password, used to ensure consistency. -/// Indicates whether two-factor authentication (2FA) should be enabled for the new account. +/// The desired username for the new account. Required. +/// The password for the new account. Required. +/// The confirmation of the entered password, used to ensure consistency. Required. +/// Indicates whether two-factor authentication (2FA) should be enabled for the new account. Optional. [DebuggerDisplay("Username: {Username}")] public record RegistrationRequest( string? Username = null, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoriesRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoriesRequest.cs index e7400cce..7bcff9cb 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoriesRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoriesRequest.cs @@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Directories; /// /// Represents a request to get the directories of a file system path. /// -/// The file system path for which to get the directories. -/// Whether to include hidden file system elements or not. +/// The file system path for which to get the directories. Required. +/// Whether to include hidden file system elements or not. Optional. [DebuggerDisplay("Path: {Path}")] public record GetDirectoriesRequest( string? Path, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoryTreeRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoryTreeRequest.cs index b88a621f..a6414176 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoryTreeRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetDirectoryTreeRequest.cs @@ -8,9 +8,9 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Directories; /// /// Represents a request to get the tree of directories that make up a file system path. /// -/// The file system path for which to get the directory tree. -/// Whether to include files along the directories or not. -/// Whether to include hidden file system elements or not. +/// The file system path for which to get the directory tree. Required. +/// Whether to include files along the directories or not. Optional. +/// Whether to include hidden file system elements or not. Optional. [DebuggerDisplay("Path: {Path}")] public record GetDirectoryTreeRequest( string? Path, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetTreeDirectoriesRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetTreeDirectoriesRequest.cs index 70bff675..0a5e1f10 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetTreeDirectoriesRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Directories/GetTreeDirectoriesRequest.cs @@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Directories; /// /// Represents a request to get the directories of a file system path. /// -/// The file system path for which to get the directory tree. -/// Whether to include hidden file system elements or not. +/// The file system path for which to get the directory tree. Required. +/// Whether to include hidden file system elements or not. Optional. [DebuggerDisplay("Path: {Path}")] public record GetTreeDirectoriesRequest( string? Path, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetFilesRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetFilesRequest.cs index a24d1c6d..e751efc9 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetFilesRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetFilesRequest.cs @@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Files; /// /// Represents a request to get the files at a file system path. /// -/// The file system path for which to get the files. -/// Whether to include hidden file system elements or not. +/// The file system path for which to get the files. Required. +/// Whether to include hidden file system elements or not. Optional. [DebuggerDisplay("Path: {Path}")] public record GetFilesRequest( string? Path, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetTreeFilesRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetTreeFilesRequest.cs index 530bd93b..a5660c6f 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetTreeFilesRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Files/GetTreeFilesRequest.cs @@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Files; /// /// Represents a request to get the files of a file system path. /// -/// The file system path for which to get the tree files. -/// Whether to include hidden file system elements or not. +/// The file system path for which to get the tree files. Required. +/// Whether to include hidden file system elements or not. Optional. [DebuggerDisplay("Path: {Path}")] public record GetTreeFilesRequest( string? Path, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CheckPathExistsRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CheckPathExistsRequest.cs index 6a7ac216..16990e50 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CheckPathExistsRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CheckPathExistsRequest.cs @@ -8,8 +8,8 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path; /// /// Represents a request to check the existence of a file system path. /// -/// The file system path to check the exitence of. -/// Whether to include hidden elements in the search results, or not. +/// The file system path to check the exitence of. Required. +/// Whether to include hidden elements in the search results, or not. Optional. [DebuggerDisplay("Path: {Path}, IncludeHiddenElements: {IncludeHiddenElements}")] public record CheckPathExistsRequest( string? Path, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CombinePathRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CombinePathRequest.cs index ccdc57fe..780a169a 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CombinePathRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/CombinePathRequest.cs @@ -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; /// /// Represents a request to get the root of a file system path. /// -/// The file system path to combine to. -/// The file system path to combine with. +/// The file system path to combine to. Required. +/// The file system path to combine with. Required. [DebuggerDisplay("OriginalPath: {OriginalPath}, NewPath: {NewPath}")] public record CombinePathRequest( string? OriginalPath, diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathParentRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathParentRequest.cs index 647fa21e..38538c11 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathParentRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathParentRequest.cs @@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path; /// /// Represents a request to get the root of a file system path. /// -/// The file system path for which to get the root. +/// The file system path for which to get the root. Required. [DebuggerDisplay("Path: {Path}")] public record GetPathParentRequest( string? Path diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathRootRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathRootRequest.cs index a0cf7eb9..9426f978 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathRootRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/GetPathRootRequest.cs @@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path; /// /// Represents a request to get the root of a file system path. /// -/// The file system path for which to get the root. +/// The file system path for which to get the root. Required. [DebuggerDisplay("Path: {Path}")] public record GetPathRootRequest( string? Path diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/SplitPathRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/SplitPathRequest.cs index a312bc90..1976daf0 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/SplitPathRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/SplitPathRequest.cs @@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path; /// /// Represents a request to split a file system path. /// -/// The file system path for which to get the path segments. +/// The file system path for which to get the path segments. Required. [DebuggerDisplay("Path: {Path}")] public record SplitPathRequest( string? Path diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/ValidatePathRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/ValidatePathRequest.cs index cb5e5096..b1826517 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Path/ValidatePathRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Path/ValidatePathRequest.cs @@ -8,7 +8,7 @@ namespace Lumina.Contracts.Requests.FileSystemManagement.Path; /// /// Represents a request to check the validity of a file system path. /// -/// The file system path to validate. +/// The file system path to validate. Required. [DebuggerDisplay("Path: {Path}")] public record ValidatePathRequest( string? Path diff --git a/src/Lumina.Contracts/Requests/FileSystemManagement/Thumbnails/GetThumbnailRequest.cs b/src/Lumina.Contracts/Requests/FileSystemManagement/Thumbnails/GetThumbnailRequest.cs index 46012f9b..90354fd0 100644 --- a/src/Lumina.Contracts/Requests/FileSystemManagement/Thumbnails/GetThumbnailRequest.cs +++ b/src/Lumina.Contracts/Requests/FileSystemManagement/Thumbnails/GetThumbnailRequest.cs @@ -1,6 +1,5 @@ #region ========================================================================= USING ===================================================================================== using System.Diagnostics; -using System.Text.Json.Serialization; #endregion namespace Lumina.Contracts.Requests.FileSystemManagement.Thumbnails; diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs index 1bd437c9..149076da 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs @@ -9,10 +9,10 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management; /// /// Represents a request to add a media library. /// -/// The Id of the user owning the media library. -/// The title of the media library. -/// The type of the media library. -/// The file system paths of the directories where the media library elements are located. +/// The Id of the user owning the media library. Required. +/// The title of the media library. Required. +/// The type of the media library. Required. +/// The file system paths of the directories where the media library elements are located. Required. [DebuggerDisplay("Title: {Title}")] public record AddLibraryRequest( Guid UserId, diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs index de10e15a..a6c2b4e1 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs @@ -12,23 +12,23 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra /// /// Represents a request to add a book. /// -/// Written content metadata of the book. -/// The format of the book (e.g., Hardcover, Paperback), if applicable. -/// The edition of the book, if applicable. -/// The volume or book number in the series, if applicable. -/// The series name, if the book is part of a series. -/// The ASIN (Amazon Standard Identification Number) of the book, if applicable. -/// The Goodreads ID of the book, if applicable. -/// The Library of Congress Control Number (LCCN) of the book, if applicable. -/// The OCLC Number (WorldCat identifier) of the book, if applicable. -/// The Open Library ID of the book, if applicable. -/// The LibraryThing ID of the book, if applicable. -/// The Google Books ID of the book, if applicable. -/// The Barnes & Noble ID of the book, if applicable. -/// The Apple Books ID of the book, if applicable. -/// The list of ISBN (International Standard Book Number) of the book. -/// The list of media contributors (actors, directors, etc) starring in this book. -/// The list of ratings for this book. +/// Written content metadata of the book. Required. +/// The format of the book (e.g., Hardcover, Paperback). Optional. +/// The edition of the book. Optional. +/// The volume or book number in the series. Optional. +/// The series name, if the book is part of a series. Optional. +/// The ASIN (Amazon Standard Identification Number) of the book. Optional. +/// The Goodreads Id of the book. Optional. +/// The Library of Congress Control Number (LCCN) of the book. Optional. +/// The OCLC Number (WorldCat identifier) of the book. Optional. +/// The Open Library Id of the book. Optional. +/// The LibraryThing Id of the book. Optional. +/// The Google Books Id of the book. Optional. +/// The Barnes & Noble Id of the book. Optional. +/// The Apple Books Id of the book. Optional. +/// The list of ISBN (International Standard Book Number) of the book. Required. +/// The list of media contributors (actors, directors, etc) starring in this book. Required. +/// The list of ratings for this book. Required. [DebuggerDisplay("Title: {Metadata.Title}")] public record AddBookRequest( WrittenContentMetadataDto? Metadata, diff --git a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs index 48a160b1..5cbec4bd 100644 --- a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs +++ b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs @@ -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(); + + 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 }); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Common/BaseEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Common/BaseEndpoint.cs index d6a33427..baad5781 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Common/BaseEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Common/BaseEndpoint.cs @@ -94,10 +94,10 @@ public abstract class BaseEndpoint : Endpoint 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>(200, "The list of directories for the specified path is returned."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpoint.cs index 4b6b7703..f613131e 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpoint.cs @@ -40,7 +40,6 @@ public class GetDirectoryTreeEndpoint : BaseEndpoint 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>(200, "The directory tree structure for the specified path."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpoint.cs index fb24cd65..3ead407a 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpoint.cs @@ -39,7 +39,6 @@ public class GetTreeDirectoriesEndpoint : BaseEndpoint 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>(200, "The directory tree structure is returned."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpoint.cs index af4de3d6..82dffb3e 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpoint.cs @@ -38,7 +38,6 @@ public class GetDrivesEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Drives.GET_DRIVES); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs index d6b5ddbc..2e3f4563 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs @@ -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 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>(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" + } + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpoint.cs index 249320e9..914df7e0 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpoint.cs @@ -40,7 +40,6 @@ public class GetTypeEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.FileSystem.GET_TYPES); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs index 7aaf65bb..e241deaa 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs @@ -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 API endpoint, for Swagger. /// [ExcludeFromCodeCoverage] -public class GetTypeEndpointSummary : Summary +public class GetTypeEndpointSummary : Summary { /// /// Initializes a new instance of the class. @@ -20,6 +21,39 @@ public class GetTypeEndpointSummary : Summary Summary = "Gets the type of the file system."; Description = "Returns the type of the file system."; - Response(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" + } + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpoint.cs index 48abc6da..dd7e09dd 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpoint.cs @@ -39,7 +39,6 @@ public class GetFilesEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Files.GET_FILES); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs index 831d31c8..e45bcf27 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs @@ -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 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>(200, "The list of files is returned."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpoint.cs index 4894a63a..a17d199c 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpoint.cs @@ -39,7 +39,6 @@ public class GetTreeFilesEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Files.GET_TREE_FILES); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs index 49be978e..03e37673 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs @@ -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 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>(200, "The tree structure of files is returned."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpoint.cs index 685481eb..8f5317d0 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpoint.cs @@ -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 : BaseEndpointCancellation token that can be used to stop the execution. public override async Task ExecuteAsync(CheckPathExistsRequest request, CancellationToken cancellationToken) { - PathExistsResponse result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false); - return TypedResults.Ok(result); + ErrorOr result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs index c8a159e1..7968ab0b 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs @@ -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 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(200, "Indicates whether the file system path exists."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpoint.cs index 31d1f71b..aabf25b1 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpoint.cs @@ -38,7 +38,6 @@ public class CombinePathEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Path.COMBINE); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs index 3babebc1..da4bf4dc 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs @@ -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 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(200, "Successfully combined the paths."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpoint.cs index aa5ce86c..4ed03330 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpoint.cs @@ -39,7 +39,6 @@ public class GetPathParentEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Path.GET_PATH_PARENT); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs index 44e2d177..a8c4bb31 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs @@ -22,9 +22,79 @@ public class GetPathParentEndpointSummary : Summary r.Path, "The path for which to get the parent directory."); + ExampleRequest = new GetPathParentRequest( + Path: "/media/movies/" + ); - Response>(200, "The parent directory of the requested path is returned."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpoint.cs index 2b39ad17..70fd55da 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpoint.cs @@ -38,7 +38,6 @@ public class GetPathRootEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Path.GET_PATH_ROOT); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs index 57e558b4..4f633984 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs @@ -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 r.Path, "The file system path for which to get the root."); - - Response(200, "The root of the requested path is returned."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpoint.cs index 1126fc6d..2afc6259 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpoint.cs @@ -35,7 +35,6 @@ public class GetPathSeparatorEndpoint : EndpointWithoutRequest Verbs(Http.GET); Routes(ApiRoutes.Path.GET_PATH_SEPARATOR); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs index 28aa7765..3945e9d4 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs @@ -20,6 +20,39 @@ public class GetPathSeparatorEndpointSummary : Summary 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(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" + } + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpoint.cs index f826749b..7f62f048 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpoint.cs @@ -39,7 +39,6 @@ public class SplitPathEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Path.SPLIT); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs index f0df92ec..7b9f808d 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs @@ -22,9 +22,68 @@ public class SplitPathEndpointSummary : Summary r.Path, "The file system path for which to get the path segments."); + ExampleRequest = new SplitPathRequest( + Path: "/media/movies/" + ); - Response>(200, "Successfully split the path into segments."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpoint.cs index 459d6b51..e1129c65 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpoint.cs @@ -37,7 +37,6 @@ public class ValidatePathEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Path.VALIDATE); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs index 011ccc4c..e2193df8 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs @@ -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 r.Path, "The file system path to validate."); + ExampleRequest = new ValidatePathRequest( + Path: "/media/movies/" + ); - Response(200, "The requested path is validated."); - Response(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpoint.cs index 0c3d8bd1..78387bdb 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpoint.cs @@ -40,7 +40,6 @@ public class GetThumbnailEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Thumbnails.GET_THUMBNAIL); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs index cbaad9ef..83d9ac26 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs @@ -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 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(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 + { + { + "General.Validation", new[] + { + "PathCannotBeEmpty", + "ImageQaulityMustBeBetweenZeroAndOneHundred" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpoint.cs index 5c5ae48a..16146459 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpoint.cs @@ -38,7 +38,6 @@ public class AddBookEndpoint : BaseEndpoint Verbs(Http.POST); Routes(ApiRoutes.Books.ADD_BOOK); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs index 3df13595..eb6f917d 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs @@ -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 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() { + { new(Name: "fantasy") }, + { new(Name: "adventure") }, + { new(Name: "classic") } + }, + Tags: new List() { + { 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(r => r.Id, "The unique identifier of the entity."); ResponseParam(r => r.Created, "The date and time when the entity was created."); @@ -47,7 +174,226 @@ public class AddLibraryEndpointSummary : Summary(r => r.Metadata, "The written content metadata of the book."); ResponseParam(r => r.Metadata.Title, "The title of the media item."); ResponseParam(r => r.Metadata.OriginalTitle, "The original title of the media item."); - Response(201, "The book was successfully created.", "The location of the created resource is provided in the Location header."); - Response(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() { + { new(Name: "fantasy") }, + { new(Name: "adventure") }, + { new(Name: "classic") } + }, + Tags: new List() { + { 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 + { + { + "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" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpoint.cs index e89bd44a..70c75c63 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpoint.cs @@ -38,7 +38,6 @@ public class GetBooksEndpoint : BaseEndpoint Verbs(Http.GET); Routes(ApiRoutes.Books.GET_BOOKS); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs index 49a7af53..718ee24a 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs @@ -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 Summary = "Retrieves the list of books."; Description = "Returns the entire list of books."; - Response>(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() { + { new(Name: "fantasy") }, + { new(Name: "adventure") }, + { new(Name: "classic") } + }, + Tags: new List() { + { 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() { + { new(Name: "fantasy") }, + { new(Name: "adventure") }, + { new(Name: "classic") } + }, + Tags: new List() { + { 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" + } + } + ); + } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpoint.cs index 3bdee2a2..142e01f4 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpoint.cs @@ -38,7 +38,6 @@ public class AddLibraryEndpoint : BaseEndpoint Verbs(Http.POST); Routes(ApiRoutes.Libraries.ADD_LIBRARY); Version(1); - AllowAnonymous(); DontCatchExceptions(); } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs index b5519fe2..e5ca1c03 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs @@ -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 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(r => r.Id, "The unique identifier of the entity."); ResponseParam(r => r.UserId, "The Id of the user owning the media library."); @@ -35,7 +48,76 @@ public class AddLibraryEndpointSummary : Summary(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located."); ResponseParam(r => r.Created, "The date and time when the entity was created."); ResponseParam(r => r.Updated, "The date and time when the entity was last updated."); - Response(201, "The media library was successfully created.", "The location of the created resource is provided in the Location header."); - Response(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 + { + { + "General.Validation", new[] + { + "UserIdCannotBeEmpty", + "LibraryTypeCannotBeNull", + "UnknownLibraryType", + "PathsListCannotBeNull", + "PathsListCannotBeEmpty", + "PathCannotBeEmpty", + "TitleCannotBeEmpty", + "TitleMustBeMaximum255CharactersLong" + } + } + }, + traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs index 56ffe275..229b6ba1 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs @@ -20,6 +20,9 @@ public class CheckInitializationEndpointSummary : Summary(200, "The application initialization status is returned."); + Response(200, "The application initialization status is returned.", + example: new InitializationResponse( + IsInitialized: true + )); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs index 1c08943b..0f5307b7 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs @@ -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 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(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 + { + { + "General.Validation", new[] + { + "UsernameCannotBeEmpty", + "PassordCannotBeEmpty", + "InvalidPassword", + "PasswordConfirmCannotBeEmpty", + "PasswordsNotMatch" + } + } + }, + traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs index 24a4eb2f..36bfa97a 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs @@ -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 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(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 + { + { + "General.Validation", new[] + { + "UsernameCannotBeEmpty", + "CurrentPasswordCannotBeEmpty", + "NewPasswordCannotBeEmpty", + "NewPasswordConfirmCannotBeEmpty", + "InvalidPassword", + "PasswordsNotMatch" + } + } + }, + traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs index 8ba72585..f9a59207 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs @@ -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 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(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 + { + { + "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" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs index af3f3afe..3c6a29ff 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs @@ -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 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(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 + { + { + "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" + } + ); } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs index 04f87c13..546aa0fb 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs @@ -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 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(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 + { + { + "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" + } + ); } } diff --git a/src/Lumina.Presentation.Web/Views/Auth/Register.cshtml b/src/Lumina.Presentation.Web/Views/Auth/Register.cshtml index 71cebdee..34de75e1 100644 --- a/src/Lumina.Presentation.Web/Views/Auth/Register.cshtml +++ b/src/Lumina.Presentation.Web/Views/Auth/Register.cshtml @@ -64,7 +64,7 @@
@@ -86,7 +86,7 @@ @if (User?.Identity?.IsAuthenticated == false) { - + }
@@ -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")'; + }); } diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs index 3bc59acd..92dc3a05 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs @@ -156,9 +156,9 @@ public class GetDirectoriesEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/directories/get-directories"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs index cd0c8f84..a9169e67 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs @@ -332,9 +332,9 @@ public class GetDirectoryTreeEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/directories/get-directory-tree"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -361,9 +361,9 @@ public class GetDirectoryTreeEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/directories/get-directory-tree"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs index eb32d295..847a1efb 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs @@ -199,9 +199,9 @@ public class GetTreeDirectoriesEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/directories/get-tree-directories"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs index 189d8b77..449bd731 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs @@ -195,9 +195,9 @@ public class GetFilesEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/files/get-files"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs index 4c2c2f7b..47494845 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs @@ -195,9 +195,9 @@ public class GetTreeFilesEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/files/get-tree-files"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs index 87af0661..3eab4fad 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs @@ -77,9 +77,9 @@ public class CombinePathEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/combine"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs index 3f1cfec4..ac45955a 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs @@ -118,9 +118,9 @@ public class GetPathParentEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/get-path-parent"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -145,9 +145,9 @@ public class GetPathParentEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/get-path-parent"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs index ea284760..3bbcf614 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs @@ -75,9 +75,9 @@ public class GetPathRootEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/get-path-root"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -102,9 +102,9 @@ public class GetPathRootEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/get-path-root"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs index 41b9fe0e..47a28109 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs @@ -75,9 +75,9 @@ public class SplitPathEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/split"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -101,9 +101,9 @@ public class SplitPathEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/split"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs index 67a97b4d..f7417729 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs @@ -99,9 +99,9 @@ public class GetThumbnailEndpointTests : IClassFixture, IClass Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/thumbnails/get-thumbnail"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -125,9 +125,9 @@ public class GetThumbnailEndpointTests : IClassFixture, IClass Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/thumbnails/get-thumbnail"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs index e6cb419c..bb694a02 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs @@ -106,8 +106,8 @@ public class ChangePasswordEndpointTests : IClassFixture, IDis problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/change-password"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -189,8 +189,8 @@ public class ChangePasswordEndpointTests : IClassFixture, IDis problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/change-password"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs index 7f468272..69a55363 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/LoginEndpointTests.cs @@ -217,8 +217,8 @@ public class LoginEndpointTests : IClassFixture, IDisposable problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/login"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs index 1b8cc3b7..0f1c09f3 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs @@ -153,8 +153,8 @@ public class RecoverPasswordEndpointTests : IClassFixture, IDi problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/recover-password"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -179,8 +179,8 @@ public class RecoverPasswordEndpointTests : IClassFixture, IDi problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/recover-password"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -210,8 +210,8 @@ public class RecoverPasswordEndpointTests : IClassFixture, IDi problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/recover-password"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); @@ -255,8 +255,8 @@ public class RecoverPasswordEndpointTests : IClassFixture, IDi problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); - problemDetails["title"].GetString().Should().Be("Validation Error"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["title"].GetString().Should().Be("General.Validation"); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["instance"].GetString().Should().Be("/api/v1/auth/recover-password"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/WrittenContentLibrary/BookLibrary/Books/AddBookEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/WrittenContentLibrary/BookLibrary/Books/AddBookEndpointTests.cs index 1f53e632..d174dff7 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/WrittenContentLibrary/BookLibrary/Books/AddBookEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/WrittenContentLibrary/BookLibrary/Books/AddBookEndpointTests.cs @@ -1577,9 +1577,9 @@ public class AddBookEndpointTests : IClassFixture Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/books"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace(); diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthLoginTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthLoginTests.cs index d8c74341..f53670d3 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthLoginTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthLoginTests.cs @@ -173,7 +173,7 @@ public class AuthLoginTests : IClassFixture, IDisposable problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7231#section-6.5.29"); problemDetails["title"].GetString().Should().Be("TooManyRequests"); problemDetails["detail"].GetString().Should().Be("Too many attempts. Please try again later."); - problemDetails["retryAfter"].GetString().Should().Be("15"); + problemDetails["retryAfter"].GetString().Should().Be("900"); lastResponse.Headers.Should().ContainKey("X-RateLimit-Limit"); lastResponse.Headers.Should().ContainKey("X-RateLimit-Reset"); diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRecoverPasswordTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRecoverPasswordTests.cs index b2268000..1604f976 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRecoverPasswordTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRecoverPasswordTests.cs @@ -69,7 +69,7 @@ public class AuthRecoverPasswordTests : IClassFixture, IDispos problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7231#section-6.5.29"); problemDetails["title"].GetString().Should().Be("TooManyRequests"); problemDetails["detail"].GetString().Should().Be("Too many attempts. Please try again later."); - problemDetails["retryAfter"].GetString().Should().Be("15"); + problemDetails["retryAfter"].GetString().Should().Be("900"); lastResponse.Headers.Should().ContainKey("X-RateLimit-Limit"); lastResponse.Headers.Should().ContainKey("X-RateLimit-Reset"); diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRegisterTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRegisterTests.cs index 306cfce7..2d14b8ba 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRegisterTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/UsersManagement/Authentication/AuthRegisterTests.cs @@ -102,7 +102,7 @@ public class AuthRegisterTests : IClassFixture, IDisposable problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7231#section-6.5.29"); problemDetails["title"].GetString().Should().Be("TooManyRequests"); problemDetails["detail"].GetString().Should().Be("Too many attempts. Please try again later."); - problemDetails["retryAfter"].GetString().Should().Be("15"); + problemDetails["retryAfter"].GetString().Should().Be("900"); lastResponse.Headers.Should().ContainKey("X-RateLimit-Limit"); lastResponse.Headers.Should().ContainKey("X-RateLimit-Reset"); diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Common/BaseEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Common/BaseEndpointTests.cs index 77a60786..d3eb1fd5 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Common/BaseEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Common/BaseEndpointTests.cs @@ -57,8 +57,8 @@ public class BaseEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().HaveCount(2); validationProblemDetails.Errors["Code1"].Should().BeEquivalentTo(["Description1"]); @@ -112,8 +112,8 @@ public class BaseEndpointTests ProblemHttpResult problemResult = (ProblemHttpResult)result; problemResult.StatusCode.Should().Be(422); problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - problemResult.ProblemDetails.Title.Should().Be("Validation Error"); - problemResult.ProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + problemResult.ProblemDetails.Title.Should().Be("General.Validation"); + problemResult.ProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); problemResult.ProblemDetails.Instance.Should().NotBeNull(); problemResult.ProblemDetails.Extensions.Should().ContainKey("traceId"); } @@ -159,8 +159,8 @@ public class BaseEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().HaveCount(2); validationProblemDetails.Errors["Code1"].Should().BeEquivalentTo(["Description1"]); diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs index 4039a33a..4d70a1f7 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs @@ -108,8 +108,8 @@ public class GetDirectoriesEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs index 50de4ade..7bc15455 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTreeEndpointTests.cs @@ -111,8 +111,8 @@ public class GetDirectoryTreeEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs index edde8820..5dfe109e 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectoriesEndpointTests.cs @@ -111,8 +111,8 @@ public class GetTreeDirectoriesEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs index 5e819ebd..fd8b8e75 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetFilesEndpointTests.cs @@ -110,8 +110,8 @@ public class GetFilesEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs index b247bd38..28391894 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFilesEndpointTests.cs @@ -111,8 +111,8 @@ public class GetTreeFilesEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs index 85533cec..aaf8fd0e 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/CombinePathEndpointTests.cs @@ -107,8 +107,8 @@ public class CombinePathEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs index 8acd397d..94c2bae5 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathParentEndpointTests.cs @@ -109,8 +109,8 @@ public class GetPathParentEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs index d43874a1..e1a1173c 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/GetPathRootEndpointTests.cs @@ -107,8 +107,8 @@ public class GetPathRootEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs index f15823f4..ebe33498 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Path/SplitPathEndpointTests.cs @@ -82,8 +82,8 @@ public class SplitPathEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs index 147c5c82..78a8f7fa 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnailEndpointTests.cs @@ -107,8 +107,8 @@ public class GetThumbnailEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); - validationProblemDetails.Detail.Should().Be("One or more validation errors occurred."); + validationProblemDetails.Title.Should().Be("General.Validation"); + validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs index 3892f8fa..6d6946a0 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs @@ -78,7 +78,7 @@ public class ChangePasswordEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); + validationProblemDetails.Title.Should().Be("General.Validation"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs index 68938298..38414672 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs @@ -78,7 +78,7 @@ public class LoginEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); + validationProblemDetails.Title.Should().Be("General.Validation"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs index 24c18032..cbc05bac 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs @@ -78,7 +78,7 @@ public class RecoverPasswordEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); + validationProblemDetails.Title.Should().Be("General.Validation"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs index 6bfb335f..f0c4f176 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs @@ -69,7 +69,7 @@ public class RegisterEndpointTests .Returns(expectedError); // Act - IResult result = await _sut.ExecuteAsync(request, cancellationToken); + IResult result = await _sut. ExecuteAsync(request, cancellationToken); // Assert result.Should().BeOfType(); @@ -79,7 +79,7 @@ public class RegisterEndpointTests problemDetails.ProblemDetails.Should().BeOfType(); HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails; validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity); - validationProblemDetails.Title.Should().Be("Validation Error"); + validationProblemDetails.Title.Should().Be("General.Validation"); validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); validationProblemDetails.Errors.Should().ContainSingle() .Which.Should().BeEquivalentTo(new From 364d56fe5675be0e6a62a91a2e2577cea3fa8d4d Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Sat, 16 Nov 2024 16:03:36 +0200 Subject: [PATCH 2/2] Updates test to new production code --- .../FileSystemManagement/Path/CheckPathExistsEndpointTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExistsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExistsEndpointTests.cs index 9846e247..b0d24390 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExistsEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExistsEndpointTests.cs @@ -99,9 +99,9 @@ public class CheckPathExistsEndpointTests : IClassFixture? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions); problemDetails.Should().NotBeNull(); problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status422UnprocessableEntity); - problemDetails["title"].GetString().Should().Be("Validation Error"); + problemDetails["title"].GetString().Should().Be("General.Validation"); problemDetails["instance"].GetString().Should().Be("/api/v1/path/check-path-exists"); - problemDetails["detail"].GetString().Should().Be("One or more validation errors occurred."); + problemDetails["detail"].GetString().Should().Be("OneOrMoreValidationErrorsOccurred"); problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2"); problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();