Descriptions for Records and DTOs

This commit is contained in:
2025-09-06 16:40:19 +02:00
parent 09e6b07186
commit d4ea40a875
9 changed files with 87 additions and 19 deletions

View File

@@ -1,14 +1,21 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace API.Controllers.DTOs; namespace API.Controllers.DTOs;
public sealed record FileLibrary(string Key, string BasePath, string LibraryName) : Identifiable(Key) public sealed record FileLibrary(string Key, string BasePath, string LibraryName) : Identifiable(Key)
{ {
[StringLength(256)] /// <summary>
/// The directory Path of the library
/// </summary>
[Required] [Required]
[Description("The directory Path of the library")]
public string BasePath { get; internal set; } = BasePath; public string BasePath { get; internal set; } = BasePath;
[StringLength(512)] /// <summary>
/// The Name of the library
/// </summary>
[Required] [Required]
[Description("The Name of the library")]
public string LibraryName { get; internal set; } = LibraryName; public string LibraryName { get; internal set; } = LibraryName;
} }

View File

@@ -1,3 +1,4 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using API.Schema.LibraryContext.LibraryConnectors; using API.Schema.LibraryContext.LibraryConnectors;
@@ -5,11 +6,18 @@ namespace API.Controllers.DTOs;
public record LibraryConnector(string Key, string BaseUrl, LibraryType Type) : Identifiable(Key) public record LibraryConnector(string Key, string BaseUrl, LibraryType Type) : Identifiable(Key)
{ {
[StringLength(256)] /// <summary>
/// The Url of the Library instance
/// </summary>
[Required] [Required]
[Url] [Url]
public string BaseUrl {get; init;} = BaseUrl; [Description("The Url of the Library instance")]
public string BaseUrl { get; init;} = BaseUrl;
/// <summary>
/// The <see cref="LibraryType"/>
/// </summary>
[Required] [Required]
[Description("The Library Type")]
public LibraryType Type { get; init; } = Type; public LibraryType Type { get; init; } = Type;
} }

View File

@@ -1,4 +1,5 @@
using API.Schema.MangaContext; using API.Controllers.Requests;
using API.Schema.MangaContext;
using Asp.Versioning; using Asp.Versioning;
using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -120,7 +121,6 @@ public class FileLibraryController(MangaContext context) : Controller
return TypedResults.Created(string.Empty, library.Key); return TypedResults.Created(string.Empty, library.Key);
} }
public sealed record CreateLibraryRecord(string BasePath, string LibraryName);
/// <summary> /// <summary>
/// Deletes the <see cref="FileLibraryId"/>.LibraryName with <paramref name="FileLibraryId"/> /// Deletes the <see cref="FileLibraryId"/>.LibraryName with <paramref name="FileLibraryId"/>

View File

@@ -1,4 +1,5 @@
using API.Schema.LibraryContext; using API.Controllers.Requests;
using API.Schema.LibraryContext;
using API.Schema.LibraryContext.LibraryConnectors; using API.Schema.LibraryContext.LibraryConnectors;
using Asp.Versioning; using Asp.Versioning;
using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Http.HttpResults;
@@ -75,7 +76,6 @@ public class LibraryConnectorController(LibraryContext context) : Controller
return TypedResults.InternalServerError(result.exceptionMessage); return TypedResults.InternalServerError(result.exceptionMessage);
return TypedResults.Created(string.Empty, connector.Key); return TypedResults.Created(string.Empty, connector.Key);
} }
public sealed record CreateLibraryConnectorRecord(LibraryType LibraryType, string Url, string Username, string Password);
/// <summary> /// <summary>
/// Deletes <see cref="LibraryConnector"/> with <paramref name="LibraryConnectorId"/> /// Deletes <see cref="LibraryConnector"/> with <paramref name="LibraryConnectorId"/>

View File

@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis; using API.Controllers.DTOs;
using API.Controllers.DTOs;
using API.Schema.MangaContext; using API.Schema.MangaContext;
using API.Workers; using API.Workers;
using Asp.Versioning; using Asp.Versioning;

View File

@@ -0,0 +1,37 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using API.Schema.LibraryContext.LibraryConnectors;
namespace API.Controllers.Requests;
public sealed record CreateLibraryConnectorRecord(LibraryType LibraryType, string Url, string Username, string Password)
{
/// <summary>
/// The <see cref="LibraryType"/>
/// </summary>
[Required]
[Description("The Library Type")]
public LibraryType LibraryType { get; init; } = LibraryType;
/// <summary>
/// The Url of the Library instance
/// </summary>
[Required]
[Url]
[Description("The Url of the Library instance")]
public string Url { get; init; } = Url;
/// <summary>
/// The Username to authenticate to the Library instance
/// </summary>
[Required]
[Description("The Username to authenticate to the Library instance")]
public string Username { get; init; } = Username;
/// <summary>
/// The Password to authenticate to the Library instance
/// </summary>
[Required]
[Description("The Password to authenticate to the Library instance")]
public string Password { get; init; } = Password;
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace API.Controllers.Requests;
public sealed record CreateLibraryRecord(string BasePath, string LibraryName)
{
/// <summary>
/// The directory Path of the library
/// </summary>
[Required]
[Description("The directory Path of the library")]
public string BasePath { get; init; } = BasePath;
/// <summary>
/// The Name of the library
/// </summary>
[Required]
[Description("The Name of the library")]
public string LibraryName { get; init; } = LibraryName;
}

View File

@@ -10,9 +10,9 @@ namespace API.Schema.LibraryContext.LibraryConnectors;
public abstract class LibraryConnector : Identifiable public abstract class LibraryConnector : Identifiable
{ {
public LibraryType LibraryType { get; init; } public LibraryType LibraryType { get; init; }
public string BaseUrl { get; init; } [StringLength(256)] [Url] public string BaseUrl { get; init; }
public string Auth { get; init; } [StringLength(256)] public string Auth { get; init; }
protected ILog Log { get; init; } [NotMapped] protected ILog Log { get; init; }
protected LibraryConnector(LibraryType libraryType, string baseUrl, string auth) protected LibraryConnector(LibraryType libraryType, string baseUrl, string auth)
: base() : base()

View File

@@ -7,13 +7,9 @@ namespace API.Schema.MangaContext;
public class FileLibrary(string basePath, string libraryName) public class FileLibrary(string basePath, string libraryName)
: Identifiable(TokenGen.CreateToken(typeof(FileLibrary), basePath)) : Identifiable(TokenGen.CreateToken(typeof(FileLibrary), basePath))
{ {
[StringLength(256)] [StringLength(256)] public string BasePath { get; internal set; } = basePath;
[Required]
public string BasePath { get; internal set; } = basePath;
[StringLength(512)] [StringLength(512)] public string LibraryName { get; internal set; } = libraryName;
[Required]
public string LibraryName { get; internal set; } = libraryName;
public override string ToString() => $"{base.ToString()} {LibraryName} - {BasePath}"; public override string ToString() => $"{base.ToString()} {LibraryName} - {BasePath}";
} }