mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Adds book details and editing with cover uploads across the stack
This commit is contained in:
1 parent
c2715dea2e
commit
1bfa07ba5d
103 files changed
+8782
-387
No files matched your search
+1
-1
@@ -88,7 +88,7 @@ public class GetThumbnailEndpointSummary : Summary<GetThumbnailEndpoint, GetThum
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"PathCannotBeEmpty",
|
||||
"ImageQaulityMustBeBetweenZeroAndOneHundred"
|
||||
"ImageQualityMustBeBetweenZeroAndOneHundred"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -123,12 +123,12 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"UserIdCannotBeEmpty",
|
||||
"LibraryTypeCannotBeNull",
|
||||
"UnknownLibraryType",
|
||||
"PathsListCannotBeNull",
|
||||
"PathsListCannotBeEmpty",
|
||||
"PathCannotBeEmpty",
|
||||
"PathMustBeMaximum260CharactersLong",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"CoverFileMustBeAnImage"
|
||||
|
||||
-1
@@ -128,7 +128,6 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"UserIdCannotBeEmpty",
|
||||
"LibraryIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -151,13 +151,14 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"UserIdCannotBeEmpty",
|
||||
"LibraryTypeCannotBeNull",
|
||||
"LibraryTypeCannotBeNull",
|
||||
"UnknownLibraryType",
|
||||
"PathsListCannotBeNull",
|
||||
"PathsListCannotBeEmpty",
|
||||
"PathCannotBeEmpty",
|
||||
"PathMustBeMaximum260CharactersLong",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong"
|
||||
}
|
||||
|
||||
+80
-23
@@ -18,12 +18,12 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.B
|
||||
/// Class used for providing a textual description for the <see cref="AddBookEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest>
|
||||
public class AddBookEndpointSummary : Summary<AddBookEndpoint, AddBookRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddLibraryEndpointSummary"/> class.
|
||||
/// Initializes a new instance of the <see cref="AddBookEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public AddLibraryEndpointSummary()
|
||||
public AddBookEndpointSummary()
|
||||
{
|
||||
Summary = "Adds a new book.";
|
||||
Description = "Creates a new book and returns its details, including the location of the newly created resource.";
|
||||
@@ -130,6 +130,8 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
]
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library this book belongs to. Required.");
|
||||
RequestParam(r => r.Path, "The file system path of the book. Required.");
|
||||
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.");
|
||||
@@ -171,13 +173,55 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
RequestParam(r => r.Contributors, "The list of media contributors (actors, directors, etc) starring in this book. Required.");
|
||||
RequestParam(r => r.Ratings, "The list of ratings for this book. Required.");
|
||||
|
||||
ResponseParam<BookResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<BookResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<BookResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
ResponseParam<BookResponse>(r => r.Id, "The unique identifier of the book.");
|
||||
ResponseParam<BookResponse>(r => r.LibraryId, "The Id of the media library the book belongs to.");
|
||||
ResponseParam<BookResponse>(r => r.Path, "The file system path of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata, "The written content metadata of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata.Title, "The title of the media item.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata.OriginalTitle, "The original title of the media item.");
|
||||
// TODO: continue response params
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Title, "The title of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalTitle, "The original title of the book, if different from the current title.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Description, "A brief description or summary of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo, "The release information of the book, including its release date and other relevant details.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.OriginalReleaseDate, "The original release date of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.OriginalReleaseYear, "The original release year of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReReleaseDate, "The re-release date of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReReleaseYear, "The re-release year of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReleaseCountry, "The country where the book was released.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReleaseVersion, "The version or edition of the release of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Genres, "The list of genres of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Tags, "The list of tags of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language, "The language in which the book is written.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.LanguageCode, "The ISO code of the language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.LanguageName, "The name of the language of the book in English.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.NativeName, "The native name of the language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage, "The original language of the book, if it has been translated.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.LanguageCode, "The ISO code of the original language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.LanguageName, "The name of the original language of the book in English.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.NativeName, "The native name of the original language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Publisher, "The publisher of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.PageCount, "The number of pages of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Format, "The format of the book (e.g., Hardcover, Paperback), if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Edition, "The edition of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.VolumeNumber, "The volume or book number in the series, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Series, "The series the book is part of, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Series!.Title, "The title of the series the book is part of.");
|
||||
ResponseParam<BookResponse>(r => r.ASIN, "The ASIN (Amazon Standard Identification Number) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.GoodreadsId, "The Goodreads ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.LCCN, "The Library of Congress Control Number (LCCN) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.OCLCNumber, "The OCLC Number (WorldCat identifier) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.OpenLibraryId, "The Open Library ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.LibraryThingId, "The LibraryThing ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.GoogleBooksId, "The Google Books ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.BarnesAndNobleId, "The Barnes & Noble ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.AppleBooksId, "The Apple Books ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.ISBNs, "The list of ISBN (International Standard Book Number) of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Contributors, "The list of media contributors starring in this book.");
|
||||
ResponseParam<BookResponse>(r => r.Ratings, "The list of ratings for the book.");
|
||||
ResponseParam<BookResponse>(r => r.MetadataStatus, "The status of the metadata enrichment of the book.");
|
||||
ResponseParam<BookResponse>(r => r.LastMetadataUpdateUtc, "The date and time when the metadata of the book was last enriched, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.MetadataProvider, "The name of the plugin that enriched the metadata of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.CreatedOnUtc, "The date and time when the book was created.");
|
||||
ResponseParam<BookResponse>(r => r.UpdatedOnUtc, "The date and time when the book was last updated, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.CoverPath, "The path of the cover image of the book, if available.");
|
||||
|
||||
Response(201, "The new book is returned.", example:
|
||||
new BookResponse(
|
||||
@@ -196,16 +240,18 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
ReleaseCountry: "uk",
|
||||
ReleaseVersion: "50th Anniversary Edition"
|
||||
),
|
||||
Genres: new List<GenreDto>() {
|
||||
{ new(Name: "fantasy") },
|
||||
{ new(Name: "adventure") },
|
||||
{ new(Name: "classic") }
|
||||
},
|
||||
Tags: new List<TagDto>() {
|
||||
{ new(Name: "epic fantasy") },
|
||||
{ new(Name: "quest") },
|
||||
{ new(Name: "middle-earth") }
|
||||
},
|
||||
Genres:
|
||||
[
|
||||
new(Name: "fantasy"),
|
||||
new(Name: "adventure"),
|
||||
new(Name: "classic")
|
||||
],
|
||||
Tags:
|
||||
[
|
||||
new(Name: "epic fantasy"),
|
||||
new(Name: "quest"),
|
||||
new(Name: "middle-earth")
|
||||
],
|
||||
Language: new(
|
||||
LanguageCode: "en",
|
||||
LanguageName: "English",
|
||||
@@ -321,6 +367,18 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/books",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
@@ -334,6 +392,9 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"BookLibraryCannotBeNull",
|
||||
"BookPathCannotBeEmpty",
|
||||
"MetadataCannotBeNull",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"OriginalTitleMustBeMaximum255CharactersLong",
|
||||
@@ -347,7 +408,6 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
"ReReleaseDateAndYearMustMatch",
|
||||
"ReReleaseYearCannotBeEarlierThanOriginalReleaseYear",
|
||||
"ReReleaseDateCannotBeEarlierThanOriginalReleaseDate",
|
||||
"ReReleaseDateAndYearMustMatch",
|
||||
"GenresListCannotBeNull",
|
||||
"GenreNameCannotBeEmpty",
|
||||
"GenreNameMustBeMaximum50CharactersLong",
|
||||
@@ -360,13 +420,10 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
|
||||
"LanguageNameMustBeMaximum50CharactersLong",
|
||||
"LanguageNativeNameMustBeMaximum50CharactersLong",
|
||||
"PublisherMustBeMaximum100CharactersLong",
|
||||
"UnknownBookFormat",
|
||||
"PageCountMustBeGreaterThanZero",
|
||||
"UnknownBookFormat",
|
||||
"EditionMustBeMaximum50CharactersLong",
|
||||
"VolumeNumberMustBeGreaterThanZero",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"AsinMustBe10CharactersLong",
|
||||
"GoodreadsIdMustBeNumeric",
|
||||
"InvalidLccnFormat",
|
||||
|
||||
+20
-6
@@ -1,5 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBook;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -14,6 +19,17 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.B
|
||||
/// </summary>
|
||||
public class GetBookEndpoint : BaseEndpoint<GetBookRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetBookQuery, Result<BookResponse>> _getBookQueryHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetBookEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="getBookQueryHandler">Injected service for handling get book queries.</param>
|
||||
public GetBookEndpoint(IQueryHandler<GetBookQuery, Result<BookResponse>> getBookQueryHandler)
|
||||
{
|
||||
_getBookQueryHandler = getBookQueryHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
@@ -22,19 +38,17 @@ public class GetBookEndpoint : BaseEndpoint<GetBookRequest, IResult>
|
||||
Verbs(FastEndpoints.Http.GET);
|
||||
Routes(ApiRoutes.Books.GET_BOOK_BY_ID);
|
||||
Version(1);
|
||||
AllowAnonymous();
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a book stored in <paramref name="request"/>.
|
||||
/// Gets the book identified by <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the book to be added.</param>
|
||||
/// <param name="request">The request containing the Id of the book to get.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetBookRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
//Result<Book> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
//return result.Match(success => TypedResults.CreatedAtRoute($"/api/v1/books/{success.Id}", success), Problem);
|
||||
return await Task.FromResult(TypedResults.Ok());
|
||||
Result<BookResponse> result = await _getBookQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBook;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetBookEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBookEndpointSummary : Summary<GetBookEndpoint, GetBookRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetBookEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetBookEndpointSummary()
|
||||
{
|
||||
Summary = "Gets a book by its Id.";
|
||||
Description = "Gets the full details of the book identified by the request, including the resolved names of its media contributors.";
|
||||
|
||||
ExampleRequest = new GetBookRequest(
|
||||
Id: Guid.NewGuid().ToString()
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the book to get. Required.");
|
||||
|
||||
ResponseParam<BookResponse>(r => r.Id, "The Id of the book.");
|
||||
ResponseParam<BookResponse>(r => r.LibraryId, "The Id of the media library the book belongs to.");
|
||||
ResponseParam<BookResponse>(r => r.Path, "The file system path of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata, "The written content metadata of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Title, "The title of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalTitle, "The original title of the book, if different from the current title.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Description, "A brief description or summary of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo, "The release information of the book, including its release date and other relevant details.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.OriginalReleaseDate, "The original release date of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.OriginalReleaseYear, "The original release year of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReReleaseDate, "The re-release date of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReReleaseYear, "The re-release year of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReleaseCountry, "The country where the book was released.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReleaseVersion, "The version or edition of the release of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Genres, "The list of genres of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Tags, "The list of tags of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language, "The language in which the book is written.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.LanguageCode, "The ISO code of the language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.LanguageName, "The name of the language of the book in English.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.NativeName, "The native name of the language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage, "The original language of the book, if it has been translated.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.LanguageCode, "The ISO code of the original language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.LanguageName, "The name of the original language of the book in English.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.NativeName, "The native name of the original language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Publisher, "The publisher of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.PageCount, "The number of pages of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Format, "The format of the book (e.g., Hardcover, Paperback), if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Edition, "The edition of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.VolumeNumber, "The volume or book number in the series, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Series, "The series the book is part of, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Series!.Title, "The title of the series the book is part of.");
|
||||
ResponseParam<BookResponse>(r => r.ASIN, "The ASIN (Amazon Standard Identification Number) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.GoodreadsId, "The Goodreads ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.LCCN, "The Library of Congress Control Number (LCCN) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.OCLCNumber, "The OCLC Number (WorldCat identifier) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.OpenLibraryId, "The Open Library ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.LibraryThingId, "The LibraryThing ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.GoogleBooksId, "The Google Books ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.BarnesAndNobleId, "The Barnes & Noble ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.AppleBooksId, "The Apple Books ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.ISBNs, "The list of ISBN (International Standard Book Number) of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Contributors, "The list of media contributors starring in this book.");
|
||||
ResponseParam<BookResponse>(r => r.Ratings, "The list of ratings for the book.");
|
||||
ResponseParam<BookResponse>(r => r.MetadataStatus, "The status of the metadata enrichment of the book.");
|
||||
ResponseParam<BookResponse>(r => r.LastMetadataUpdateUtc, "The date and time when the metadata of the book was last enriched, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.MetadataProvider, "The name of the plugin that enriched the metadata of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.CreatedOnUtc, "The date and time when the book was created.");
|
||||
ResponseParam<BookResponse>(r => r.UpdatedOnUtc, "The date and time when the book was last updated, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.CoverPath, "The path of the cover image of the book, if available.");
|
||||
|
||||
Response(200, "The requested book is returned.",
|
||||
example: new BookResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Path: "/books/the-fellowship-of-the-ring.epub",
|
||||
Metadata: new WrittenContentMetadataDto(
|
||||
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 ReleaseInfoDto(
|
||||
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(Name: "fantasy"),
|
||||
new(Name: "adventure"),
|
||||
new(Name: "classic")
|
||||
],
|
||||
Tags:
|
||||
[
|
||||
new(Name: "epic fantasy"),
|
||||
new(Name: "quest"),
|
||||
new(Name: "middle-earth")
|
||||
],
|
||||
Language: new LanguageInfoDto(
|
||||
LanguageCode: "en",
|
||||
LanguageName: "English",
|
||||
NativeName: "English"
|
||||
),
|
||||
OriginalLanguage: new LanguageInfoDto(
|
||||
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 IsbnDto(
|
||||
Value: "0395272238",
|
||||
Format: IsbnFormat.Isbn10
|
||||
),
|
||||
new IsbnDto(
|
||||
Value: "9780395272237",
|
||||
Format: IsbnFormat.Isbn13
|
||||
)
|
||||
],
|
||||
Contributors:
|
||||
[
|
||||
new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "J.R.R. Tolkien",
|
||||
LegalName: "John Ronald Reuel Tolkien"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "author",
|
||||
Category: MediaContributorRoleCategory.Author
|
||||
)
|
||||
),
|
||||
new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "Alan Lee",
|
||||
LegalName: "Alan Lee"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "illustrator",
|
||||
Category: MediaContributorRoleCategory.Illustrator
|
||||
)
|
||||
)
|
||||
],
|
||||
Ratings:
|
||||
[
|
||||
new BookRatingDto(
|
||||
Source: BookRatingSource.GoogleBooks,
|
||||
Value: 4.36M,
|
||||
MaxValue: 5,
|
||||
VoteCount: 2345678
|
||||
),
|
||||
new BookRatingDto(
|
||||
Source: BookRatingSource.Amazon,
|
||||
Value: 4.7M,
|
||||
MaxValue: 5,
|
||||
VoteCount: 87654
|
||||
)
|
||||
],
|
||||
MetadataStatus: MetadataStatus.Enriched,
|
||||
LastMetadataUpdateUtc: DateTime.UtcNow,
|
||||
MetadataProvider: "GoogleBooks",
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: DateTime.UtcNow,
|
||||
CoverPath: "/media/books/books-3f2504e0-4f89-41d3-9a0c-0305e82c3301/The Lord of the Rings-2b0e5f5a-0b3f-4b7e-8f4a-8c9e3d2f5a6b/cover.jpg"
|
||||
)
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/books/{id}"
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/books/{id}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the book 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 = "BookNotFound",
|
||||
instance = "/api/v1/books/{id}",
|
||||
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/books/{id}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"BookIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -112,7 +112,8 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty"
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"InvalidFilterAlphaKey"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBook;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.UpdateBook;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books/{id}</c> route.
|
||||
/// </summary>
|
||||
public class UpdateBookEndpoint : BaseEndpoint<UpdateBookRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<UpdateBookCommand, Result<BookResponse>> _updateBookCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateBookEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="updateBookCommandHandler">Injected service for handling update book commands.</param>
|
||||
public UpdateBookEndpoint(ICommandHandler<UpdateBookCommand, Result<BookResponse>> updateBookCommandHandler)
|
||||
{
|
||||
_updateBookCommandHandler = updateBookCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(FastEndpoints.Http.PUT);
|
||||
Routes(ApiRoutes.Books.UPDATE_BOOK);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the book described in <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the edited details of the book.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(UpdateBookRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
// The book is identified by the {id} route value, not by the id of the request body, so that a mismatched or malicious id can never
|
||||
// redirect the update to another book; the raw value is kept as a string, so that an unparseable id reaches the command validator,
|
||||
// which reports it with a ProblemDetails validation error instead of failing the request binding.
|
||||
request = request with { Id = HttpContext.Request.RouteValues["id"]?.ToString() };
|
||||
|
||||
Result<BookResponse> result = await _updateBookCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+460
@@ -0,0 +1,460 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.UpdateBook;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="UpdateBookEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateBookEndpointSummary : Summary<UpdateBookEndpoint, UpdateBookRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateBookEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public UpdateBookEndpointSummary()
|
||||
{
|
||||
Summary = "Updates a book.";
|
||||
Description = "Updates the details of the book identified by the request.";
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the book to update. Required.");
|
||||
RequestParam(r => r.Metadata, "The written content metadata of the book. Required.");
|
||||
RequestParam(r => r.Metadata!.Title, "The title of the book. Required.");
|
||||
RequestParam(r => r.Metadata!.OriginalTitle, "The original title of the book, if different from the current title. Optional.");
|
||||
RequestParam(r => r.Metadata!.Description, "A brief description or summary of the book. 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 book. Optional.");
|
||||
RequestParam(r => r.Metadata!.ReleaseInfo!.OriginalReleaseYear, "The original release year of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.ReleaseInfo!.ReReleaseDate, "The re-release date of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.ReleaseInfo!.ReReleaseYear, "The re-release year of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.ReleaseInfo!.ReleaseCountry, "The country where the book was released. Optional.");
|
||||
RequestParam(r => r.Metadata!.ReleaseInfo!.ReleaseVersion, "The version or edition of the release of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.Genres, "The list of genres of the book. Required.");
|
||||
RequestParam(r => r.Metadata!.Tags, "The list of tags of the book. Required.");
|
||||
RequestParam(r => r.Metadata!.Language, "The language in which the book is written. Optional.");
|
||||
RequestParam(r => r.Metadata!.Language!.LanguageCode, "The ISO code of the language of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.Language!.LanguageName, "The name of the language of the book in English. Optional.");
|
||||
RequestParam(r => r.Metadata!.Language!.NativeName, "The native name of the language of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.OriginalLanguage, "The original language of the book, if it has been translated. Optional.");
|
||||
RequestParam(r => r.Metadata!.OriginalLanguage!.LanguageCode, "The ISO code of the original language of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.OriginalLanguage!.LanguageName, "The name of the original language of the book in English. Optional.");
|
||||
RequestParam(r => r.Metadata!.OriginalLanguage!.NativeName, "The native name of the original language of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.Publisher, "The publisher of the book. Optional.");
|
||||
RequestParam(r => r.Metadata!.PageCount, "The number of pages of the book. 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 the book is part of. Optional.");
|
||||
RequestParam(r => r.Series!.Title, "The title of the series the book is part of. Optional.");
|
||||
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 of the book. Required.");
|
||||
RequestParam(r => r.Ratings, "The list of ratings of the book. Required.");
|
||||
|
||||
ExampleRequest = new UpdateBookRequest(
|
||||
Id: Guid.NewGuid().ToString(),
|
||||
Metadata: new WrittenContentMetadataDto(
|
||||
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 ReleaseInfoDto(
|
||||
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(Name: "fantasy"),
|
||||
new(Name: "adventure"),
|
||||
new(Name: "classic")
|
||||
],
|
||||
Tags:
|
||||
[
|
||||
new(Name: "epic fantasy"),
|
||||
new(Name: "quest"),
|
||||
new(Name: "middle-earth")
|
||||
],
|
||||
Language: new LanguageInfoDto(
|
||||
LanguageCode: "en",
|
||||
LanguageName: "English",
|
||||
NativeName: "English"
|
||||
),
|
||||
OriginalLanguage: new LanguageInfoDto(
|
||||
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 IsbnDto(
|
||||
Value: "0395272238",
|
||||
Format: IsbnFormat.Isbn10
|
||||
),
|
||||
new IsbnDto(
|
||||
Value: "9780395272237",
|
||||
Format: IsbnFormat.Isbn13
|
||||
)
|
||||
],
|
||||
Contributors:
|
||||
[
|
||||
new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "J.R.R. Tolkien",
|
||||
LegalName: "John Ronald Reuel Tolkien"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "author",
|
||||
Category: MediaContributorRoleCategory.Author
|
||||
)
|
||||
),
|
||||
new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "Alan Lee",
|
||||
LegalName: "Alan Lee"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "illustrator",
|
||||
Category: MediaContributorRoleCategory.Illustrator
|
||||
)
|
||||
)
|
||||
],
|
||||
Ratings:
|
||||
[
|
||||
new BookRatingDto(
|
||||
Source: BookRatingSource.GoogleBooks,
|
||||
Value: 4.36M,
|
||||
MaxValue: 5,
|
||||
VoteCount: 2345678
|
||||
),
|
||||
new BookRatingDto(
|
||||
Source: BookRatingSource.Amazon,
|
||||
Value: 4.7M,
|
||||
MaxValue: 5,
|
||||
VoteCount: 87654
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
ResponseParam<BookResponse>(r => r.Id, "The Id of the book.");
|
||||
ResponseParam<BookResponse>(r => r.LibraryId, "The Id of the media library the book belongs to.");
|
||||
ResponseParam<BookResponse>(r => r.Path, "The file system path of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata, "The written content metadata of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Title, "The title of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalTitle, "The original title of the book, if different from the current title.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Description, "A brief description or summary of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo, "The release information of the book, including its release date and other relevant details.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.OriginalReleaseDate, "The original release date of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.OriginalReleaseYear, "The original release year of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReReleaseDate, "The re-release date of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReReleaseYear, "The re-release year of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReleaseCountry, "The country where the book was released.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.ReleaseInfo!.ReleaseVersion, "The version or edition of the release of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Genres, "The list of genres of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Tags, "The list of tags of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language, "The language in which the book is written.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.LanguageCode, "The ISO code of the language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.LanguageName, "The name of the language of the book in English.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Language!.NativeName, "The native name of the language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage, "The original language of the book, if it has been translated.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.LanguageCode, "The ISO code of the original language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.LanguageName, "The name of the original language of the book in English.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.OriginalLanguage!.NativeName, "The native name of the original language of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.Publisher, "The publisher of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Metadata!.PageCount, "The number of pages of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Format, "The format of the book (e.g., Hardcover, Paperback), if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Edition, "The edition of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.VolumeNumber, "The volume or book number in the series, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Series, "The series the book is part of, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.Series!.Title, "The title of the series the book is part of.");
|
||||
ResponseParam<BookResponse>(r => r.ASIN, "The ASIN (Amazon Standard Identification Number) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.GoodreadsId, "The Goodreads ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.LCCN, "The Library of Congress Control Number (LCCN) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.OCLCNumber, "The OCLC Number (WorldCat identifier) of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.OpenLibraryId, "The Open Library ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.LibraryThingId, "The LibraryThing ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.GoogleBooksId, "The Google Books ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.BarnesAndNobleId, "The Barnes & Noble ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.AppleBooksId, "The Apple Books ID of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.ISBNs, "The list of ISBN (International Standard Book Number) of the book.");
|
||||
ResponseParam<BookResponse>(r => r.Contributors, "The list of media contributors starring in this book.");
|
||||
ResponseParam<BookResponse>(r => r.Ratings, "The list of ratings for the book.");
|
||||
ResponseParam<BookResponse>(r => r.MetadataStatus, "The status of the metadata enrichment of the book.");
|
||||
ResponseParam<BookResponse>(r => r.LastMetadataUpdateUtc, "The date and time when the metadata of the book was last enriched, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.MetadataProvider, "The name of the plugin that enriched the metadata of the book, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.CreatedOnUtc, "The date and time when the book was created.");
|
||||
ResponseParam<BookResponse>(r => r.UpdatedOnUtc, "The date and time when the book was last updated, if applicable.");
|
||||
ResponseParam<BookResponse>(r => r.CoverPath, "The path of the cover image of the book, if available.");
|
||||
|
||||
Response(200, "The updated book is returned.",
|
||||
example: new BookResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Path: "/books/the-fellowship-of-the-ring.epub",
|
||||
Metadata: new WrittenContentMetadataDto(
|
||||
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 ReleaseInfoDto(
|
||||
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(Name: "fantasy"),
|
||||
new(Name: "adventure"),
|
||||
new(Name: "classic")
|
||||
],
|
||||
Tags:
|
||||
[
|
||||
new(Name: "epic fantasy"),
|
||||
new(Name: "quest"),
|
||||
new(Name: "middle-earth")
|
||||
],
|
||||
Language: new LanguageInfoDto(
|
||||
LanguageCode: "en",
|
||||
LanguageName: "English",
|
||||
NativeName: "English"
|
||||
),
|
||||
OriginalLanguage: new LanguageInfoDto(
|
||||
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 IsbnDto(
|
||||
Value: "0395272238",
|
||||
Format: IsbnFormat.Isbn10
|
||||
),
|
||||
new IsbnDto(
|
||||
Value: "9780395272237",
|
||||
Format: IsbnFormat.Isbn13
|
||||
)
|
||||
],
|
||||
Contributors:
|
||||
[
|
||||
new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "J.R.R. Tolkien",
|
||||
LegalName: "John Ronald Reuel Tolkien"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "author",
|
||||
Category: MediaContributorRoleCategory.Author
|
||||
)
|
||||
),
|
||||
new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "Alan Lee",
|
||||
LegalName: "Alan Lee"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "illustrator",
|
||||
Category: MediaContributorRoleCategory.Illustrator
|
||||
)
|
||||
)
|
||||
],
|
||||
Ratings:
|
||||
[
|
||||
new BookRatingDto(
|
||||
Source: BookRatingSource.GoogleBooks,
|
||||
Value: 4.36M,
|
||||
MaxValue: 5,
|
||||
VoteCount: 2345678
|
||||
),
|
||||
new BookRatingDto(
|
||||
Source: BookRatingSource.Amazon,
|
||||
Value: 4.7M,
|
||||
MaxValue: 5,
|
||||
VoteCount: 87654
|
||||
)
|
||||
],
|
||||
MetadataStatus: MetadataStatus.Enriched,
|
||||
LastMetadataUpdateUtc: DateTime.UtcNow,
|
||||
MetadataProvider: "GoogleBooks",
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: DateTime.UtcNow,
|
||||
CoverPath: "/media/books/books-3f2504e0-4f89-41d3-9a0c-0305e82c3301/The Lord of the Rings-2b0e5f5a-0b3f-4b7e-8f4a-8c9e3d2f5a6b/cover.jpg"
|
||||
)
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/books/{id}"
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/books/{id}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the book or its media library 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 = "BookNotFound",
|
||||
instance = "/api/v1/books/{id}",
|
||||
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/books/{id}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"BookIdCannotBeEmpty",
|
||||
"MetadataCannotBeNull",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"OriginalTitleMustBeMaximum255CharactersLong",
|
||||
"DescriptionMustBeMaximum2000CharactersLong",
|
||||
"ReleaseInfoCannotBeNull",
|
||||
"OriginalReleaseYearMustBeBetween1And9999",
|
||||
"ReReleaseYearMustBeBetween1And9999",
|
||||
"CountryCodeMustBe2CharactersLong",
|
||||
"ReleaseVersionMustBeMaximum50CharactersLong",
|
||||
"OriginalReleaseDateAndYearMustMatch",
|
||||
"ReReleaseDateAndYearMustMatch",
|
||||
"ReReleaseYearCannotBeEarlierThanOriginalReleaseYear",
|
||||
"ReReleaseDateCannotBeEarlierThanOriginalReleaseDate",
|
||||
"GenresListCannotBeNull",
|
||||
"GenreNameCannotBeEmpty",
|
||||
"GenreNameMustBeMaximum50CharactersLong",
|
||||
"TagsListCannotBeNull",
|
||||
"TagNameCannotBeEmpty",
|
||||
"TagNameMustBeMaximum50CharactersLong",
|
||||
"LanguageCodeCannotBeEmpty",
|
||||
"LanguageCodeMustBe2CharactersLong",
|
||||
"LanguageNameCannotBeEmpty",
|
||||
"LanguageNameMustBeMaximum50CharactersLong",
|
||||
"LanguageNativeNameMustBeMaximum50CharactersLong",
|
||||
"PublisherMustBeMaximum100CharactersLong",
|
||||
"PageCountMustBeGreaterThanZero",
|
||||
"UnknownBookFormat",
|
||||
"EditionMustBeMaximum50CharactersLong",
|
||||
"VolumeNumberMustBeGreaterThanZero",
|
||||
"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",
|
||||
"RatingsListCannotBeNull",
|
||||
"RatingValueMustBePositive",
|
||||
"RatingValueCannotBeGreaterThanMaxValue",
|
||||
"RatingMaxValueMustBePositive",
|
||||
"RatingVoteCountMustBePositive"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBookCover;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.UpdateBookCover;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books/{id}/cover</c> route.
|
||||
/// </summary>
|
||||
public class UpdateBookCoverEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly Application.Common.CQRS.ICommandHandler<UpdateBookCoverCommand, Result<string>> _updateBookCoverCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateBookCoverEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="updateBookCoverCommandHandler">Injected service for handling update book cover commands.</param>
|
||||
public UpdateBookCoverEndpoint(Application.Common.CQRS.ICommandHandler<UpdateBookCoverCommand, Result<string>> updateBookCoverCommandHandler)
|
||||
{
|
||||
_updateBookCoverCommandHandler = updateBookCoverCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.PUT);
|
||||
Routes(ApiRoutes.Books.UPDATE_BOOK_COVER);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the cover image of the book with the image uploaded in the multipart form of the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
// The endpoint takes no typed request, because its body is a multipart file, so the book id is read from the {id} route
|
||||
// value; an unparseable value becomes Guid.Empty, which the command validator reports as a missing book id.
|
||||
Guid bookId = Guid.TryParse(HttpContext.Request.RouteValues["id"]?.ToString(), out Guid parsedBookId) ? parsedBookId : Guid.Empty;
|
||||
|
||||
IFormFile? cover = null;
|
||||
if (HttpContext.Request.HasFormContentType)
|
||||
{
|
||||
try
|
||||
{
|
||||
// The cover is the first file of the multipart form; a multipart body without any file cannot be parsed as a form,
|
||||
// so a malformed upload is treated as a missing cover, which the command validator reports.
|
||||
cover = HttpContext.Request.Form.Files.Count > 0 ? HttpContext.Request.Form.Files[0] : null;
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
cover = null;
|
||||
}
|
||||
}
|
||||
|
||||
// The cover stream must stay open while the handler stores the image, and is disposed as soon as the handler returns.
|
||||
UpdateBookCoverCommand command = new(bookId, cover?.OpenReadStream(), cover?.FileName);
|
||||
try
|
||||
{
|
||||
Result<string> result = await _updateBookCoverCommandHandler.HandleAsync(command, cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
finally
|
||||
{
|
||||
command.Cover?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.UpdateBookCover;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="UpdateBookCoverEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateBookCoverEndpointSummary : Summary<UpdateBookCoverEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateBookCoverEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public UpdateBookCoverEndpointSummary()
|
||||
{
|
||||
Summary = "Updates the cover image of a book.";
|
||||
Description = "Updates the cover image of the book identified by the request, with the image uploaded in the multipart form of the request.";
|
||||
|
||||
Response(200, "The relative path of the stored cover image is returned.",
|
||||
example: "/media/books/books-3f2504e0-4f89-41d3-9a0c-0305e82c3301/The Lord of the Rings-2b0e5f5a-0b3f-4b7e-8f4a-8c9e3d2f5a6b/cover.jpg"
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/books/{id}/cover"
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/books/{id}/cover",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the book or its media library 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 = "BookNotFound",
|
||||
instance = "/api/v1/books/{id}/cover",
|
||||
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/books/{id}/cover",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"BookIdCannotBeEmpty",
|
||||
"BookCoverCannotBeNull",
|
||||
"FileTooLarge",
|
||||
"CoverFileMustBeAnImage"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class SetupApplicationEndpointSummary : Summary<SetupApplicationEndpoint,
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"UsernameCannotBeEmpty",
|
||||
"PassordCannotBeEmpty",
|
||||
"PasswordCannotBeEmpty",
|
||||
"InvalidPassword",
|
||||
"PasswordConfirmCannotBeEmpty",
|
||||
"PasswordsNotMatch"
|
||||
|
||||
+2
-1
@@ -99,7 +99,8 @@ public class InstallPluginEndpointSummary : Summary<InstallPluginEndpoint, Empty
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"PluginArchiveCannotBeNull"
|
||||
"PluginArchiveCannotBeNull",
|
||||
"PluginFileNameCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -77,9 +77,9 @@ public class RegisterEndpointSummary : Summary<RegisterEndpoint, RegistrationReq
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"UsernameCannotBeEmpty",
|
||||
"PassordCannotBeEmpty",
|
||||
"UsernameMustBeBetween3And255CharactersLong",
|
||||
"InvalidUsername",
|
||||
"PasswordCannotBeEmpty",
|
||||
"InvalidPassword",
|
||||
"PasswordConfirmCannotBeEmpty",
|
||||
"PasswordsNotMatch"
|
||||
|
||||
-1
@@ -118,7 +118,6 @@ public class UpdateUserRoleAndPermissionsEndpointSummary : Summary<UpdateUserRol
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"UserIdCannotBeEmpty",
|
||||
"RoleIdCannotBeEmpty",
|
||||
"PermissionIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user