.NET 7 + Spring Cleaning (#1677)

* Updated to net7.0

* Updated GA to .net 7

* Updated System.IO.Abstractions to use New factory.

* Converted Regex into SourceGenerator in Parser.

* Updated more regex to source generators.

* Enabled Nullability and more regex changes throughout codebase.

* Parser is 100% GeneratedRegexified

* Lots of nullability code

* Enabled nullability for all repositories.

* Fixed another unit test

* Refactored some code around and took care of some todos.

* Updating code for nullability and cleaning up methods that aren't used anymore. Refctored all uses of Parser.Normalize() to use new extension

* More nullability exercises. 500 warnings to go.

* Fixed a bug where custom file uploads for entities wouldn't save in webP.

* Nullability is done for all DTOs

* Fixed all unit tests and nullability for the project. Only OPDS is left which will be done with an upcoming OPDS enhancement.

* Use localization in book service after validating

* Code smells

* Switched to preview build of swashbuckle for .net7 support

* Fixed up merge issues

* Disable emulate comic book when on single page reader

* Fixed a regression where double page renderer wouldn't layout the images correctly

* Updated to swashbuckle which support .net 7

* Fixed a bad GA action

* Some code cleanup

* More code smells

* Took care of most of nullable issues

* Fixed a broken test due to having more than one test run in parallel

* I'm really not sure why the unit tests are failing or are so extremely slow on .net 7

* Updated all dependencies

* Fixed up build and removed hardcoded framework from build scripts. (this merge removes Regex Source generators). Unit tests are completely busted.

* Unit tests and code cleanup. Needs shakeout now.

* Adjusted Series model since a few fields are not-nullable. Removed dead imports on the project.

* Refactored to use Builder pattern for all unit tests.

* Switched nullability down to warnings. It wasn't possible to switch due to constraint issues in DB Migration.
This commit is contained in:
Joe Milazzo 2023-03-05 14:55:13 -06:00 committed by GitHub
parent 76fe3fd64a
commit 5d1dd7b3f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
283 changed files with 4221 additions and 4593 deletions

View file

@ -5,12 +5,12 @@ namespace API.DTOs.Account;
public class ConfirmEmailDto
{
[Required]
public string Email { get; set; }
public string Email { get; set; } = default!;
[Required]
public string Token { get; set; }
public string Token { get; set; } = default!;
[Required]
[StringLength(32, MinimumLength = 6)]
public string Password { get; set; }
public string Password { get; set; } = default!;
[Required]
public string Username { get; set; }
public string Username { get; set; } = default!;
}

View file

@ -5,7 +5,7 @@ namespace API.DTOs.Account;
public class ConfirmEmailUpdateDto
{
[Required]
public string Email { get; set; }
public string Email { get; set; } = default!;
[Required]
public string Token { get; set; }
public string Token { get; set; } = default!;
}

View file

@ -2,6 +2,6 @@
public class ConfirmMigrationEmailDto
{
public string Email { get; set; }
public string Token { get; set; }
public string Email { get; set; } = default!;
public string Token { get; set; } = default!;
}

View file

@ -5,10 +5,10 @@ namespace API.DTOs.Account;
public class ConfirmPasswordResetDto
{
[Required]
public string Email { get; set; }
public string Email { get; set; } = default!;
[Required]
public string Token { get; set; }
public string Token { get; set; } = default!;
[Required]
[StringLength(32, MinimumLength = 6)]
public string Password { get; set; }
public string Password { get; set; } = default!;
}

View file

@ -1,24 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using API.Entities.Enums;
namespace API.DTOs.Account;
public class InviteUserDto
{
[Required]
public string Email { get; set; }
public string Email { get; set; } = default!;
/// <summary>
/// List of Roles to assign to user. If admin not present, Pleb will be applied.
/// If admin present, all libraries will be granted access and will ignore those from DTO.
/// </summary>
public ICollection<string> Roles { get; init; }
public ICollection<string> Roles { get; init; } = default!;
/// <summary>
/// A list of libraries to grant access to
/// </summary>
public IList<int> Libraries { get; init; }
public IList<int> Libraries { get; init; } = default!;
/// <summary>
/// An Age Rating which will limit the account to seeing everything equal to or below said rating.
/// </summary>
public AgeRestrictionDto AgeRestriction { get; set; }
public AgeRestrictionDto AgeRestriction { get; set; } = default!;
}

View file

@ -5,9 +5,9 @@ public class InviteUserResponse
/// <summary>
/// Email link used to setup the user account
/// </summary>
public string EmailLink { get; set; }
public string EmailLink { get; set; } = default!;
/// <summary>
/// Was an email sent (ie is this server accessible)
/// </summary>
public bool EmailSent { get; set; }
public bool EmailSent { get; set; } = default!;
}

View file

@ -2,6 +2,6 @@
public class LoginDto
{
public string Username { get; init; }
public string Password { get; set; }
public string Username { get; init; } = default!;
public string Password { get; set; } = default!;
}

View file

@ -2,8 +2,7 @@
public class MigrateUserEmailDto
{
public string Email { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public bool SendEmail { get; set; }
public string Email { get; set; } = default!;
public string Username { get; set; } = default!;
public string Password { get; set; } = default!;
}

View file

@ -8,15 +8,15 @@ public class ResetPasswordDto
/// The Username of the User
/// </summary>
[Required]
public string UserName { get; init; }
public string UserName { get; init; } = default!;
/// <summary>
/// The new password
/// </summary>
[Required]
[StringLength(32, MinimumLength = 6)]
public string Password { get; init; }
public string Password { get; init; } = default!;
/// <summary>
/// The old, existing password. If an admin is performing the change, this is not required. Otherwise, it is.
/// </summary>
public string OldPassword { get; init; }
public string OldPassword { get; init; } = default!;
}

View file

@ -2,6 +2,6 @@
public class TokenRequestDto
{
public string Token { get; init; }
public string RefreshToken { get; init; }
public string Token { get; init; } = default!;
public string RefreshToken { get; init; } = default!;
}

View file

@ -2,6 +2,6 @@
public class UpdateEmailDto
{
public string Email { get; set; }
public string Password { get; set; }
public string Email { get; set; } = default!;
public string Password { get; set; } = default!;
}

View file

@ -1,24 +1,21 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using API.Entities.Enums;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
namespace API.DTOs.Account;
public record UpdateUserDto
{
public int UserId { get; set; }
public string Username { get; set; }
public string Username { get; set; } = default!;
/// List of Roles to assign to user. If admin not present, Pleb will be applied.
/// If admin present, all libraries will be granted access and will ignore those from DTO.
public IList<string> Roles { get; init; }
public IList<string> Roles { get; init; } = default!;
/// <summary>
/// A list of libraries to grant access to
/// </summary>
public IList<int> Libraries { get; init; }
public IList<int> Libraries { get; init; } = default!;
/// <summary>
/// An Age Rating which will limit the account to seeing everything equal to or below said rating.
/// </summary>
public AgeRestrictionDto AgeRestriction { get; init; }
public AgeRestrictionDto AgeRestriction { get; init; } = default!;
}

View file

@ -2,7 +2,6 @@
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace API.DTOs;
@ -16,11 +15,11 @@ public class ChapterDto : IHasReadTimeEstimate, IEntityDate
/// <summary>
/// Range of chapters. Chapter 2-4 -> "2-4". Chapter 2 -> "2".
/// </summary>
public string Range { get; init; }
public string Range { get; init; } = default!;
/// <summary>
/// Smallest number of the Range.
/// </summary>
public string Number { get; init; }
public string Number { get; init; } = default!;
/// <summary>
/// Total number of pages in all MangaFiles
/// </summary>
@ -32,11 +31,11 @@ public class ChapterDto : IHasReadTimeEstimate, IEntityDate
/// <summary>
/// Used for books/specials to display custom title. For non-specials/books, will be set to <see cref="Range"/>
/// </summary>
public string Title { get; set; }
public string Title { get; set; } = default!;
/// <summary>
/// The files that represent this Chapter
/// </summary>
public ICollection<MangaFileDto> Files { get; init; }
public ICollection<MangaFileDto> Files { get; init; } = default!;
/// <summary>
/// Calculated at API time. Number of pages read for this Chapter for logged in user.
/// </summary>
@ -69,12 +68,12 @@ public class ChapterDto : IHasReadTimeEstimate, IEntityDate
/// Title of the Chapter/Issue
/// </summary>
/// <remarks>Metadata field</remarks>
public string TitleName { get; set; }
public string TitleName { get; set; } = default!;
/// <summary>
/// Summary of the Chapter
/// </summary>
/// <remarks>This is not set normally, only for Series Detail</remarks>
public string Summary { get; init; }
public string Summary { get; init; } = default!;
/// <summary>
/// Age Rating for the issue/chapter
/// </summary>

View file

@ -9,9 +9,9 @@ public class CollectionTagBulkAddDto
/// </summary>
/// <remarks>Can be 0 which then will use Title to create a tag</remarks>
public int CollectionTagId { get; init; }
public string CollectionTagTitle { get; init; }
public string CollectionTagTitle { get; init; } = default!;
/// <summary>
/// Series Ids to add onto Collection Tag
/// </summary>
public IEnumerable<int> SeriesIds { get; init; }
public IEnumerable<int> SeriesIds { get; init; } = default!;
}

View file

@ -3,12 +3,12 @@
public class CollectionTagDto
{
public int Id { get; set; }
public string Title { get; set; }
public string Summary { get; set; }
public string Title { get; set; } = default!;
public string Summary { get; set; } = default!;
public bool Promoted { get; set; }
/// <summary>
/// The cover image string. This is used on Frontend to show or hide the Cover Image
/// </summary>
public string CoverImage { get; set; }
public string CoverImage { get; set; } = default!;
public bool CoverImageLocked { get; set; }
}

View file

@ -4,6 +4,6 @@ namespace API.DTOs.CollectionTags;
public class UpdateSeriesForTagDto
{
public CollectionTagDto Tag { get; init; }
public IEnumerable<int> SeriesIdsToRemove { get; init; }
public CollectionTagDto Tag { get; init; } = default!;
public IEnumerable<int> SeriesIdsToRemove { get; init; } = default!;
}

View file

@ -7,10 +7,10 @@ namespace API.DTOs;
public class CreateLibraryDto
{
[Required]
public string Name { get; init; }
public string Name { get; init; } = default!;
[Required]
public LibraryType Type { get; init; }
[Required]
[MinLength(1)]
public IEnumerable<string> Folders { get; init; }
public IEnumerable<string> Folders { get; init; } = default!;
}

View file

@ -4,5 +4,5 @@ namespace API.DTOs;
public class DeleteSeriesDto
{
public IList<int> SeriesIds { get; set; }
public IList<int> SeriesIds { get; set; } = default!;
}

View file

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Runtime.InteropServices;
using API.Entities.Enums.Device;
namespace API.DTOs.Device;
@ -7,14 +6,14 @@ namespace API.DTOs.Device;
public class CreateDeviceDto
{
[Required]
public string Name { get; set; }
public string Name { get; set; } = default!;
/// <summary>
/// Platform of the device. If not know, defaults to "Custom"
/// </summary>
[Required]
public DevicePlatform Platform { get; set; }
[Required]
public string EmailAddress { get; set; }
public string EmailAddress { get; set; } = default!;
}

View file

@ -17,11 +17,11 @@ public class DeviceDto
/// </summary>
/// <remarks>If this device is web, this will be the browser name</remarks>
/// <example>Pixel 3a, John's Kindle</example>
public string Name { get; set; }
public string Name { get; set; } = default!;
/// <summary>
/// An email address associated with the device (ie Kindle). Will be used with Send to functionality
/// </summary>
public string EmailAddress { get; set; }
public string EmailAddress { get; set; } = default!;
/// <summary>
/// Platform (ie) Windows 10
/// </summary>

View file

@ -5,5 +5,5 @@ namespace API.DTOs.Device;
public class SendToDeviceDto
{
public int DeviceId { get; set; }
public IReadOnlyList<int> ChapterIds { get; set; }
public IReadOnlyList<int> ChapterIds { get; set; } = default!;
}

View file

@ -8,12 +8,12 @@ public class UpdateDeviceDto
[Required]
public int Id { get; set; }
[Required]
public string Name { get; set; }
public string Name { get; set; } = default!;
/// <summary>
/// Platform of the device. If not know, defaults to "Custom"
/// </summary>
[Required]
public DevicePlatform Platform { get; set; }
[Required]
public string EmailAddress { get; set; }
public string EmailAddress { get; set; } = default!;
}

View file

@ -7,5 +7,5 @@ namespace API.DTOs.Downloads;
public class DownloadBookmarkDto
{
[Required]
public IEnumerable<BookmarkDto> Bookmarks { get; set; }
public IEnumerable<BookmarkDto> Bookmarks { get; set; } = default!;
}

View file

@ -2,11 +2,11 @@
public class ConfirmationEmailDto
{
public string InvitingUser { get; init; }
public string EmailAddress { get; init; }
public string ServerConfirmationLink { get; init; }
public string InvitingUser { get; init; } = default!;
public string EmailAddress { get; init; } = default!;
public string ServerConfirmationLink { get; init; } = default!;
/// <summary>
/// InstallId of this Kavita Instance
/// </summary>
public string InstallId { get; init; }
public string InstallId { get; init; } = default!;
}

View file

@ -2,11 +2,11 @@
public class EmailMigrationDto
{
public string EmailAddress { get; init; }
public string Username { get; init; }
public string ServerConfirmationLink { get; init; }
public string EmailAddress { get; init; } = default!;
public string Username { get; init; } = default!;
public string ServerConfirmationLink { get; init; } = default!;
/// <summary>
/// InstallId of this Kavita Instance
/// </summary>
public string InstallId { get; init; }
public string InstallId { get; init; } = default!;
}

View file

@ -6,5 +6,5 @@
public class EmailTestResultDto
{
public bool Successful { get; set; }
public string ErrorMessage { get; set; }
public string ErrorMessage { get; set; } = default!;
}

View file

@ -2,10 +2,10 @@
public class PasswordResetEmailDto
{
public string EmailAddress { get; init; }
public string ServerConfirmationLink { get; init; }
public string EmailAddress { get; init; } = default!;
public string ServerConfirmationLink { get; init; } = default!;
/// <summary>
/// InstallId of this Kavita Instance
/// </summary>
public string InstallId { get; init; }
public string InstallId { get; init; } = default!;
}

View file

@ -4,6 +4,6 @@ namespace API.DTOs.Email;
public class SendToDto
{
public string DestinationEmail { get; set; }
public IEnumerable<string> FilePaths { get; set; }
public string DestinationEmail { get; set; } = default!;
public IEnumerable<string> FilePaths { get; set; } = default!;
}

View file

@ -2,5 +2,5 @@
public class TestEmailDto
{
public string Url { get; set; }
public string Url { get; set; } = default!;
}

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using API.Entities;
using API.Entities.Enums;
@ -81,7 +80,7 @@ public class FilterDto
/// <summary>
/// Sorting Options for a query. Defaults to null, which uses the queries natural sorting order
/// </summary>
public SortOptions SortOptions { get; set; } = null;
public SortOptions? SortOptions { get; set; } = null;
/// <summary>
/// Age Ratings. Empty list will return everything back
/// </summary>
@ -99,10 +98,8 @@ public class FilterDto
/// An optional name string to filter by. Empty string will ignore.
/// </summary>
public string SeriesNameQuery { get; init; } = string.Empty;
#nullable enable
/// <summary>
/// An optional release year to filter by. Null will ignore. You can pass 0 for an individual field to ignore it.
/// </summary>
public Range<int>? ReleaseYearRange { get; init; } = null;
#nullable disable
}

View file

@ -2,6 +2,6 @@
public class LanguageDto
{
public string IsoCode { get; set; }
public string Title { get; set; }
public required string IsoCode { get; set; }
public required string Title { get; set; }
}

View file

@ -4,8 +4,8 @@
/// </summary>
public class Range<T>
{
public T Min { get; set; }
public T Max { get; set; }
public T? Min { get; init; }
public T? Max { get; init; }
public override string ToString()
{

View file

@ -7,7 +7,7 @@ namespace API.DTOs;
/// </summary>
public class GroupedSeriesDto
{
public string SeriesName { get; set; }
public string SeriesName { get; set; } = default!;
public int SeriesId { get; set; }
public int LibraryId { get; set; }
public LibraryType LibraryType { get; set; }

View file

@ -7,11 +7,11 @@ public class JobDto
/// <summary>
/// Job Id
/// </summary>
public string Id { get; set; }
public string Id { get; set; } = default!;
/// <summary>
/// Human Readable title for the Job
/// </summary>
public string Title { get; set; }
public string Title { get; set; } = default!;
/// <summary>
/// When the job was created
/// </summary>
@ -28,5 +28,5 @@ public class JobDto
/// Last time the job was run
/// </summary>
public DateTime? LastExecutionUtc { get; set; }
public string Cron { get; set; }
public string Cron { get; set; } = default!;
}

View file

@ -9,12 +9,13 @@ public class JumpKeyDto
/// Number of items in this Key
/// </summary>
public int Size { get; set; }
/// <summary>
/// Code to use in URL (url encoded)
/// </summary>
public string Key { get; set; }
public string Key { get; set; } = default!;
/// <summary>
/// What is visible to user
/// </summary>
public string Title { get; set; }
public string Title { get; set; } = default!;
}

View file

@ -7,7 +7,7 @@ namespace API.DTOs;
public class LibraryDto
{
public int Id { get; init; }
public string Name { get; init; }
public string? Name { get; init; }
/// <summary>
/// Last time Library was scanned
/// </summary>
@ -16,7 +16,7 @@ public class LibraryDto
/// <summary>
/// An optional Cover Image or null
/// </summary>
public string CoverImage { get; init; }
public string? CoverImage { get; init; }
/// <summary>
/// If Folder Watching is enabled for this library
/// </summary>
@ -37,9 +37,9 @@ public class LibraryDto
/// Include library series in Search
/// </summary>
public bool IncludeInSearch { get; set; } = true;
public ICollection<string> Folders { get; init; } = new List<string>();
/// <summary>
/// When showing series, only parent series or series with no relationships will be returned
/// </summary>
public bool CollapseSeriesRelationships { get; set; } = false;
public ICollection<string> Folders { get; init; }
}

View file

@ -6,7 +6,7 @@ namespace API.DTOs;
public class MangaFileDto
{
public int Id { get; init; }
public string FilePath { get; init; }
public string FilePath { get; init; } = default!;
public int Pages { get; init; }
public long Bytes { get; init; }
public MangaFormat Format { get; init; }

View file

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using API.Data.Misc;
using API.DTOs.Account;
using API.Entities.Enums;
namespace API.DTOs;
@ -12,11 +10,11 @@ namespace API.DTOs;
public class MemberDto
{
public int Id { get; init; }
public string Username { get; init; }
public string Email { get; init; }
public AgeRestrictionDto AgeRestriction { get; init; }
public string? Username { get; init; }
public string? Email { get; init; }
public AgeRestrictionDto? AgeRestriction { get; init; }
public DateTime Created { get; init; }
public DateTime LastActive { get; init; }
public IEnumerable<LibraryDto> Libraries { get; init; }
public IEnumerable<string> Roles { get; init; }
public IEnumerable<LibraryDto>? Libraries { get; init; }
public IEnumerable<string>? Roles { get; init; }
}

View file

@ -5,5 +5,5 @@ namespace API.DTOs.Metadata;
public class AgeRatingDto
{
public AgeRating Value { get; set; }
public string Title { get; set; }
public required string Title { get; set; }
}

View file

@ -10,7 +10,7 @@ public class ChapterMetadataDto
{
public int Id { get; set; }
public int ChapterId { get; set; }
public string Title { get; set; }
public string Title { get; set; } = default!;
public ICollection<PersonDto> Writers { get; set; } = new List<PersonDto>();
public ICollection<PersonDto> CoverArtists { get; set; } = new List<PersonDto>();
public ICollection<PersonDto> Publishers { get; set; } = new List<PersonDto>();
@ -29,16 +29,16 @@ public class ChapterMetadataDto
/// </summary>
public ICollection<TagDto> Tags { get; set; } = new List<TagDto>();
public AgeRating AgeRating { get; set; }
public string ReleaseDate { get; set; }
public string? ReleaseDate { get; set; }
public PublicationStatus PublicationStatus { get; set; }
/// <summary>
/// Summary for the Chapter/Issue
/// </summary>
public string Summary { get; set; }
public string? Summary { get; set; }
/// <summary>
/// Language for the Chapter/Issue
/// </summary>
public string Language { get; set; }
public string? Language { get; set; }
/// <summary>
/// Number in the TotalCount of issues
/// </summary>

View file

@ -3,5 +3,5 @@
public class GenreTagDto
{
public int Id { get; set; }
public string Title { get; set; }
public required string Title { get; set; }
}

View file

@ -5,5 +5,5 @@ namespace API.DTOs.Metadata;
public class PublicationStatusDto
{
public PublicationStatus Value { get; set; }
public string Title { get; set; }
public required string Title { get; set; }
}

View file

@ -3,5 +3,5 @@
public class TagDto
{
public int Id { get; set; }
public string Title { get; set; }
public required string Title { get; set; }
}

View file

@ -8,11 +8,11 @@ public class FeedCategory
public string Scheme { get; } = "http://www.bisg.org/standards/bisac_subject/index.html";
[XmlAttribute("term")]
public string Term { get; set; }
public string Term { get; set; } = default!;
/// <summary>
/// The actual genre
/// </summary>
[XmlAttribute("label")]
public string Label { get; set; }
public string Label { get; set; } = default!;
}

View file

@ -10,13 +10,13 @@ public class FeedEntry
public string Updated { get; init; } = DateTime.UtcNow.ToString("s");
[XmlElement("id")]
public string Id { get; set; }
public required string Id { get; set; }
[XmlElement("title")]
public string Title { get; set; }
public required string Title { get; set; }
[XmlElement("summary")]
public string Summary { get; set; }
public string? Summary { get; set; }
/// <summary>
/// Represents Size of the Entry
@ -24,20 +24,20 @@ public class FeedEntry
/// <example>2 MB</example>
/// </summary>
[XmlElement("extent", Namespace = "http://purl.org/dc/terms/")]
public string Extent { get; set; }
public string? Extent { get; set; }
/// <summary>
/// Format of the file
/// https://dublincore.org/specifications/dublin-core/dcmi-terms/
/// </summary>
[XmlElement("format", Namespace = "http://purl.org/dc/terms/format")]
public string Format { get; set; }
public string? Format { get; set; }
[XmlElement("language", Namespace = "http://purl.org/dc/terms/")]
public string Language { get; set; }
public string? Language { get; set; }
[XmlElement("content")]
public FeedEntryContent Content { get; set; }
public FeedEntryContent? Content { get; set; }
[XmlElement("link")]
public List<FeedLink> Links { get; set; } = new List<FeedLink>();

View file

@ -8,29 +8,29 @@ public class OpenSearchDescription
/// <summary>
/// Contains a brief human-readable title that identifies this search engine.
/// </summary>
public string ShortName { get; set; }
public string ShortName { get; set; } = default!;
/// <summary>
/// Contains an extended human-readable title that identifies this search engine.
/// </summary>
public string LongName { get; set; }
public string LongName { get; set; } = default!;
/// <summary>
/// Contains a human-readable text description of the search engine.
/// </summary>
public string Description { get; set; }
public string Description { get; set; } = default!;
/// <summary>
/// https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md#the-url-element
/// </summary>
public SearchLink Url { get; set; }
public SearchLink Url { get; set; } = default!;
/// <summary>
/// Contains a set of words that are used as keywords to identify and categorize this search content.
/// Tags must be a single word and are delimited by the space character (' ').
/// </summary>
public string Tags { get; set; }
public string Tags { get; set; } = string.Empty;
/// <summary>
/// Contains a URL that identifies the location of an image that can be used in association with this search content.
/// <example><Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image></example>
/// </summary>
public string Image { get; set; }
public string Image { get; set; } = default!;
public string InputEncoding { get; set; } = "UTF-8";
public string OutputEncoding { get; set; } = "UTF-8";
/// <summary>

View file

@ -5,11 +5,11 @@ namespace API.DTOs.OPDS;
public class SearchLink
{
[XmlAttribute("type")]
public string Type { get; set; }
public string Type { get; set; } = default!;
[XmlAttribute("rel")]
public string Rel { get; set; } = "results";
[XmlAttribute("template")]
public string Template { get; set; }
public string Template { get; set; } = default!;
}

View file

@ -5,6 +5,6 @@ namespace API.DTOs;
public class PersonDto
{
public int Id { get; set; }
public string Name { get; set; }
public required string Name { get; set; }
public PersonRole Role { get; set; }
}

View file

@ -1,5 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace API.DTOs;
@ -19,5 +18,5 @@ public class ProgressDto
/// For EPUB reader, this can be an optional string of the id of a part marker, to help resume reading position
/// on pages that combine multiple "chapters".
/// </summary>
public string BookScrollId { get; set; }
public string? BookScrollId { get; set; }
}

View file

@ -7,14 +7,14 @@ public class BookChapterItem
/// <summary>
/// Name of the Chapter
/// </summary>
public string Title { get; set; }
public string Title { get; set; } = default!;
/// <summary>
/// A part represents the id of the anchor so we can scroll to it. 01_values.xhtml#h_sVZPaxUSy/
/// </summary>
public string Part { get; set; }
public string Part { get; set; } = default!;
/// <summary>
/// Page Number to load for the chapter
/// </summary>
public int Page { get; set; }
public ICollection<BookChapterItem> Children { get; set; }
public ICollection<BookChapterItem> Children { get; set; } = default!;
}

View file

@ -4,15 +4,15 @@ namespace API.DTOs.Reader;
public class BookInfoDto : IChapterInfoDto
{
public string BookTitle { get; set; }
public string BookTitle { get; set; } = default! ;
public int SeriesId { get; set; }
public int VolumeId { get; set; }
public MangaFormat SeriesFormat { get; set; }
public string SeriesName { get; set; }
public string ChapterNumber { get; set; }
public string VolumeNumber { get; set; }
public string SeriesName { get; set; } = default! ;
public string ChapterNumber { get; set; } = default! ;
public string VolumeNumber { get; set; } = default! ;
public int LibraryId { get; set; }
public int Pages { get; set; }
public bool IsSpecial { get; set; }
public string ChapterTitle { get; set; }
public string ChapterTitle { get; set; } = default! ;
}

View file

@ -4,7 +4,7 @@ namespace API.DTOs.Reader;
public class BookmarkInfoDto
{
public string SeriesName { get; set; }
public string SeriesName { get; set; } = default!;
public MangaFormat SeriesFormat { get; set; }
public int SeriesId { get; set; }
public int LibraryId { get; set; }

View file

@ -4,5 +4,5 @@ namespace API.DTOs.Reader;
public class BulkRemoveBookmarkForSeriesDto
{
public ICollection<int> SeriesIds { get; init; }
public ICollection<int> SeriesIds { get; init; } = default!;
}

View file

@ -11,11 +11,11 @@ public class ChapterInfoDto : IChapterInfoDto
/// <summary>
/// The Chapter Number
/// </summary>
public string ChapterNumber { get; set; }
public string ChapterNumber { get; set; } = default! ;
/// <summary>
/// The Volume Number
/// </summary>
public string VolumeNumber { get; set; }
public string VolumeNumber { get; set; } = default! ;
/// <summary>
/// Volume entity Id
/// </summary>
@ -23,7 +23,7 @@ public class ChapterInfoDto : IChapterInfoDto
/// <summary>
/// Series Name
/// </summary>
public string SeriesName { get; set; }
public string SeriesName { get; set; } = null!;
/// <summary>
/// Series Format
/// </summary>
@ -51,7 +51,7 @@ public class ChapterInfoDto : IChapterInfoDto
/// <summary>
/// File name of the chapter
/// </summary>
public string FileName { get; set; }
public string? FileName { get; set; }
/// <summary>
/// If this is marked as a special in Kavita
/// </summary>
@ -59,21 +59,22 @@ public class ChapterInfoDto : IChapterInfoDto
/// <summary>
/// The subtitle to render on the reader
/// </summary>
public string Subtitle { get; set; }
public string? Subtitle { get; set; }
/// <summary>
/// Series Title
/// </summary>
/// <remarks>Usually just series name, but can include chapter title</remarks>
public string Title { get; set; }
public string Title { get; set; } = default!;
/// <summary>
/// List of all files with their inner archive structure maintained in filename and dimensions
/// </summary>
/// <remarks>This is optionally returned by includeDimensions</remarks>
public IEnumerable<FileDimensionDto> PageDimensions { get; set; }
public IEnumerable<FileDimensionDto>? PageDimensions { get; set; }
/// <summary>
/// For Double Page reader, this will contain snap points to ensure the reader always resumes on correct page
/// </summary>
/// <remarks>This is optionally returned by includeDimensions</remarks>
public IDictionary<int, int> DoublePairs { get; set; }
public IDictionary<int, int>? DoublePairs { get; set; }
}

View file

@ -4,5 +4,5 @@ namespace API.DTOs.Reader;
public class MarkMultipleSeriesAsReadDto
{
public IReadOnlyList<int> SeriesIds { get; init; }
public IReadOnlyList<int> SeriesIds { get; init; } = default!;
}

View file

@ -11,9 +11,9 @@ public class MarkVolumesReadDto
/// <summary>
/// A list of Volumes to mark read
/// </summary>
public IReadOnlyList<int> VolumeIds { get; set; }
public IReadOnlyList<int> VolumeIds { get; set; } = default!;
/// <summary>
/// A list of additional Chapters to mark as read
/// </summary>
public IReadOnlyList<int> ChapterIds { get; set; }
public IReadOnlyList<int> ChapterIds { get; set; } = default!;
}

View file

@ -2,5 +2,5 @@
public class CreateReadingListDto
{
public string Title { get; init; }
public string Title { get; init; } = default!;
}

View file

@ -3,8 +3,8 @@
public class ReadingListDto
{
public int Id { get; init; }
public string Title { get; set; }
public string Summary { get; set; }
public string Title { get; set; } = default!;
public string Summary { get; set; } = default!;
/// <summary>
/// Reading lists that are promoted are only done by admins
/// </summary>

View file

@ -9,18 +9,18 @@ public class ReadingListItemDto
public int Order { get; init; }
public int ChapterId { get; init; }
public int SeriesId { get; init; }
public string SeriesName { get; set; }
public string? SeriesName { get; set; }
public MangaFormat SeriesFormat { get; set; }
public int PagesRead { get; set; }
public int PagesTotal { get; set; }
public string ChapterNumber { get; set; }
public string ChapterTitleName { get; set; }
public string VolumeNumber { get; set; }
public string? ChapterNumber { get; set; }
public string? VolumeNumber { get; set; }
public string? ChapterTitleName { get; set; }
public int VolumeId { get; set; }
public int LibraryId { get; set; }
public string? Title { get; set; }
public LibraryType LibraryType { get; set; }
public string LibraryName { get; set; }
public string Title { get; set; }
public string? LibraryName { get; set; }
/// <summary>
/// Release Date from Chapter
/// </summary>

View file

@ -6,6 +6,6 @@ public class UpdateReadingListByMultipleDto
{
public int SeriesId { get; init; }
public int ReadingListId { get; init; }
public IReadOnlyList<int> VolumeIds { get; init; }
public IReadOnlyList<int> ChapterIds { get; init; }
public IReadOnlyList<int> VolumeIds { get; init; } = default!;
public IReadOnlyList<int> ChapterIds { get; init; } = default!;
}

View file

@ -5,5 +5,5 @@ namespace API.DTOs.ReadingLists;
public class UpdateReadingListByMultipleSeriesDto
{
public int ReadingListId { get; init; }
public IReadOnlyList<int> SeriesIds { get; init; }
public IReadOnlyList<int> SeriesIds { get; init; } = default!;
}

View file

@ -1,5 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace API.DTOs.ReadingLists;

View file

@ -8,14 +8,14 @@ namespace API.DTOs;
/// </summary>
public class RecentlyAddedItemDto
{
public string SeriesName { get; set; }
public string SeriesName { get; set; } = default!;
public int SeriesId { get; set; }
public int LibraryId { get; set; }
public LibraryType LibraryType { get; set; }
/// <summary>
/// This will automatically map to Volume X, Chapter Y, etc.
/// </summary>
public string Title { get; set; }
public string Title { get; set; } = default!;
public DateTime Created { get; set; }
/// <summary>
/// Chapter Id if this is a chapter. Not guaranteed to be set.

View file

@ -5,12 +5,12 @@ namespace API.DTOs;
public class RegisterDto
{
[Required]
public string Username { get; init; }
public string Username { get; init; } = default!;
/// <summary>
/// An email to register with. Optional. Provides Forgot Password functionality
/// </summary>
public string Email { get; init; }
public string Email { get; init; } = default!;
[Required]
[StringLength(32, MinimumLength = 6)]
public string Password { get; set; }
public string Password { get; set; } = default!;
}

View file

@ -8,10 +8,10 @@ public class ScanFolderDto
/// <summary>
/// Api key for a user with Admin permissions
/// </summary>
public string ApiKey { get; set; }
public string ApiKey { get; set; } = default!;
/// <summary>
/// Folder Path to Scan
/// </summary>
/// <remarks>JSON cannot accept /, so you may need to use // escaping on paths</remarks>
public string FolderPath { get; set; }
public string FolderPath { get; set; } = default!;
}

View file

@ -5,13 +5,13 @@ namespace API.DTOs.Search;
public class SearchResultDto
{
public int SeriesId { get; init; }
public string Name { get; init; }
public string OriginalName { get; init; }
public string SortName { get; init; }
public string LocalizedName { get; init; }
public string Name { get; init; } = default!;
public string OriginalName { get; init; } = default!;
public string SortName { get; init; } = default!;
public string LocalizedName { get; init; } = default!;
public MangaFormat Format { get; init; }
// Grouping information
public string LibraryName { get; set; }
public string LibraryName { get; set; } = default!;
public int LibraryId { get; set; }
}

View file

@ -10,15 +10,15 @@ namespace API.DTOs.Search;
/// </summary>
public class SearchResultGroupDto
{
public IEnumerable<LibraryDto> Libraries { get; set; }
public IEnumerable<SearchResultDto> Series { get; set; }
public IEnumerable<CollectionTagDto> Collections { get; set; }
public IEnumerable<ReadingListDto> ReadingLists { get; set; }
public IEnumerable<PersonDto> Persons { get; set; }
public IEnumerable<GenreTagDto> Genres { get; set; }
public IEnumerable<TagDto> Tags { get; set; }
public IEnumerable<MangaFileDto> Files { get; set; }
public IEnumerable<ChapterDto> Chapters { get; set; }
public IEnumerable<LibraryDto> Libraries { get; set; } = default!;
public IEnumerable<SearchResultDto> Series { get; set; } = default!;
public IEnumerable<CollectionTagDto> Collections { get; set; } = default!;
public IEnumerable<ReadingListDto> ReadingLists { get; set; } = default!;
public IEnumerable<PersonDto> Persons { get; set; } = default!;
public IEnumerable<GenreTagDto> Genres { get; set; } = default!;
public IEnumerable<TagDto> Tags { get; set; } = default!;
public IEnumerable<MangaFileDto> Files { get; set; } = default!;
public IEnumerable<ChapterDto> Chapters { get; set; } = default!;
}

View file

@ -2,5 +2,5 @@
public class SeriesByIdsDto
{
public int[] SeriesIds { get; init; }
public int[] SeriesIds { get; init; } = default!;
}

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using API.Entities.Enums;
namespace API.DTOs.SeriesDetail;
@ -10,17 +9,17 @@ public class RelatedSeriesDto
/// </summary>
public int SourceSeriesId { get; set; }
public IEnumerable<SeriesDto> Sequels { get; set; }
public IEnumerable<SeriesDto> Prequels { get; set; }
public IEnumerable<SeriesDto> SpinOffs { get; set; }
public IEnumerable<SeriesDto> Adaptations { get; set; }
public IEnumerable<SeriesDto> SideStories { get; set; }
public IEnumerable<SeriesDto> Characters { get; set; }
public IEnumerable<SeriesDto> Contains { get; set; }
public IEnumerable<SeriesDto> Others { get; set; }
public IEnumerable<SeriesDto> AlternativeSettings { get; set; }
public IEnumerable<SeriesDto> AlternativeVersions { get; set; }
public IEnumerable<SeriesDto> Doujinshis { get; set; }
public IEnumerable<SeriesDto> Parent { get; set; }
public IEnumerable<SeriesDto> Editions { get; set; }
public IEnumerable<SeriesDto> Sequels { get; set; } = default!;
public IEnumerable<SeriesDto> Prequels { get; set; } = default!;
public IEnumerable<SeriesDto> SpinOffs { get; set; } = default!;
public IEnumerable<SeriesDto> Adaptations { get; set; } = default!;
public IEnumerable<SeriesDto> SideStories { get; set; } = default!;
public IEnumerable<SeriesDto> Characters { get; set; } = default!;
public IEnumerable<SeriesDto> Contains { get; set; } = default!;
public IEnumerable<SeriesDto> Others { get; set; } = default!;
public IEnumerable<SeriesDto> AlternativeSettings { get; set; } = default!;
public IEnumerable<SeriesDto> AlternativeVersions { get; set; } = default!;
public IEnumerable<SeriesDto> Doujinshis { get; set; } = default!;
public IEnumerable<SeriesDto> Parent { get; set; } = default!;
public IEnumerable<SeriesDto> Editions { get; set; } = default!;
}

View file

@ -11,19 +11,19 @@ public class SeriesDetailDto
/// <summary>
/// Specials for the Series. These will have their title and range cleaned to remove the special marker and prepare
/// </summary>
public IEnumerable<ChapterDto> Specials { get; set; }
public IEnumerable<ChapterDto> Specials { get; set; } = default!;
/// <summary>
/// All Chapters, excluding Specials and single chapters (0 chapter) for a volume
/// </summary>
public IEnumerable<ChapterDto> Chapters { get; set; }
public IEnumerable<ChapterDto> Chapters { get; set; } = default!;
/// <summary>
/// Just the Volumes for the Series (Excludes Volume 0)
/// </summary>
public IEnumerable<VolumeDto> Volumes { get; set; }
public IEnumerable<VolumeDto> Volumes { get; set; } = default!;
/// <summary>
/// These are chapters that are in Volume 0 and should be read AFTER the volumes
/// </summary>
public IEnumerable<ChapterDto> StorylineChapters { get; set; }
public IEnumerable<ChapterDto> StorylineChapters { get; set; } = default!;
/// <summary>
/// How many chapters are unread
/// </summary>

View file

@ -5,16 +5,16 @@ namespace API.DTOs.SeriesDetail;
public class UpdateRelatedSeriesDto
{
public int SeriesId { get; set; }
public IList<int> Adaptations { get; set; }
public IList<int> Characters { get; set; }
public IList<int> Contains { get; set; }
public IList<int> Others { get; set; }
public IList<int> Prequels { get; set; }
public IList<int> Sequels { get; set; }
public IList<int> SideStories { get; set; }
public IList<int> SpinOffs { get; set; }
public IList<int> AlternativeSettings { get; set; }
public IList<int> AlternativeVersions { get; set; }
public IList<int> Doujinshis { get; set; }
public IList<int> Editions { get; set; }
public IList<int> Adaptations { get; set; } = default!;
public IList<int> Characters { get; set; } = default!;
public IList<int> Contains { get; set; } = default!;
public IList<int> Others { get; set; } = default!;
public IList<int> Prequels { get; set; } = default!;
public IList<int> Sequels { get; set; } = default!;
public IList<int> SideStories { get; set; } = default!;
public IList<int> SpinOffs { get; set; } = default!;
public IList<int> AlternativeSettings { get; set; } = default!;
public IList<int> AlternativeVersions { get; set; } = default!;
public IList<int> Doujinshis { get; set; } = default!;
public IList<int> Editions { get; set; } = default!;
}

View file

@ -7,11 +7,11 @@ namespace API.DTOs;
public class SeriesDto : IHasReadTimeEstimate
{
public int Id { get; init; }
public string Name { get; init; }
public string OriginalName { get; init; }
public string LocalizedName { get; init; }
public string SortName { get; init; }
public string Summary { get; init; }
public string? Name { get; init; }
public string? OriginalName { get; init; }
public string? LocalizedName { get; init; }
public string? SortName { get; init; }
public string? Summary { get; init; }
public int Pages { get; init; }
public bool CoverImageLocked { get; set; }
/// <summary>
@ -33,7 +33,7 @@ public class SeriesDto : IHasReadTimeEstimate
/// <summary>
/// Review from logged in user. Calculated at API-time.
/// </summary>
public string UserReview { get; set; }
public string? UserReview { get; set; }
public MangaFormat Format { get; set; }
public DateTime Created { get; set; }
@ -47,7 +47,7 @@ public class SeriesDto : IHasReadTimeEstimate
public long WordCount { get; set; }
public int LibraryId { get; set; }
public string LibraryName { get; set; }
public string LibraryName { get; set; } = default!;
/// <inheritdoc cref="IHasReadTimeEstimate.MinHoursToRead"/>
public int MinHoursToRead { get; set; }
/// <inheritdoc cref="IHasReadTimeEstimate.MaxHoursToRead"/>
@ -57,7 +57,7 @@ public class SeriesDto : IHasReadTimeEstimate
/// <summary>
/// The highest level folder for this Series
/// </summary>
public string FolderPath { get; set; }
public string FolderPath { get; set; } = default!;
/// <summary>
/// The last time the folder for this series was scanned
/// </summary>

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using API.DTOs.CollectionTags;
using API.DTOs.Metadata;
using API.Entities.Enums;
@ -10,18 +9,21 @@ public class SeriesMetadataDto
{
public int Id { get; set; }
public string Summary { get; set; } = string.Empty;
/// <summary>
/// Collections the Series belongs to
/// </summary>
public ICollection<CollectionTagDto> CollectionTags { get; set; }
public ICollection<CollectionTagDto> CollectionTags { get; set; } = new List<CollectionTagDto>();
/// <summary>
/// Genres for the Series
/// </summary>
public ICollection<GenreTagDto> Genres { get; set; }
public ICollection<GenreTagDto> Genres { get; set; } = new List<GenreTagDto>();
/// <summary>
/// Collection of all Tags from underlying chapters for a Series
/// </summary>
public ICollection<TagDto> Tags { get; set; }
public ICollection<TagDto> Tags { get; set; } = new List<TagDto>();
public ICollection<PersonDto> Writers { get; set; } = new List<PersonDto>();
public ICollection<PersonDto> CoverArtists { get; set; } = new List<PersonDto>();
public ICollection<PersonDto> Publishers { get; set; } = new List<PersonDto>();

View file

@ -1,18 +1,16 @@
using System;
using System.ComponentModel.DataAnnotations;
using API.Services;
using API.Services;
namespace API.DTOs.Settings;
public class ServerSettingDto
{
public string CacheDirectory { get; set; }
public string TaskScan { get; set; }
public string CacheDirectory { get; set; } = default!;
public string TaskScan { get; set; } = default!;
/// <summary>
/// Logging level for server. Managed in appsettings.json.
/// </summary>
public string LoggingLevel { get; set; }
public string TaskBackup { get; set; }
public string LoggingLevel { get; set; } = default!;
public string TaskBackup { get; set; } = default!;
/// <summary>
/// Port the server listens on. Managed in appsettings.json.
/// </summary>
@ -32,22 +30,22 @@ public class ServerSettingDto
/// <summary>
/// Base Url for the kavita. Requires restart to take effect.
/// </summary>
public string BaseUrl { get; set; }
public string BaseUrl { get; set; } = default!;
/// <summary>
/// Where Bookmarks are stored.
/// </summary>
/// <remarks>If null or empty string, will default back to default install setting aka <see cref="DirectoryService.BookmarkDirectory"/></remarks>
public string BookmarksDirectory { get; set; }
public string BookmarksDirectory { get; set; } = default!;
/// <summary>
/// Email service to use for the invite user flow, forgot password, etc.
/// </summary>
/// <remarks>If null or empty string, will default back to default install setting aka <see cref="EmailService.DefaultApiUrl"/></remarks>
public string EmailServiceUrl { get; set; }
public string InstallVersion { get; set; }
public string EmailServiceUrl { get; set; } = default!;
public string InstallVersion { get; set; } = default!;
/// <summary>
/// Represents a unique Id to this Kavita installation. Only used in Stats to identify unique installs.
/// </summary>
public string InstallId { get; set; }
public string InstallId { get; set; } = default!;
/// <summary>
/// If the server should save bookmarks as WebP encoding
/// </summary>

View file

@ -2,6 +2,6 @@
public class StatCount<T> : ICount<T>
{
public T Value { get; set; }
public T Value { get; set; } = default!;
public long Count { get; set; }
}

View file

@ -5,7 +5,7 @@ namespace API.DTOs.Statistics;
public class FileExtensionDto
{
public string Extension { get; set; }
public string? Extension { get; set; }
public MangaFormat Format { get; set; }
public long TotalSize { get; set; }
public long TotalFiles { get; set; }
@ -17,6 +17,7 @@ public class FileExtensionBreakdownDto
/// Total bytes for all files
/// </summary>
public long TotalFileSize { get; set; }
public IList<FileExtensionDto> FileBreakdown { get; set; }
public IList<FileExtensionDto> FileBreakdown { get; set; } = default!;
}

View file

@ -1,5 +1,4 @@
using System;
using API.Entities.Enums;
using API.Entities.Enums;
namespace API.DTOs.Statistics;
@ -8,7 +7,7 @@ public class PagesReadOnADayCount<T> : ICount<T>
/// <summary>
/// The day of the readings
/// </summary>
public T Value { get; set; }
public T Value { get; set; } = default!;
/// <summary>
/// Number of pages read
/// </summary>

View file

@ -8,11 +8,11 @@ namespace API.DTOs.Statistics;
public class ReadHistoryEvent
{
public int UserId { get; set; }
public string UserName { get; set; }
public required string? UserName { get; set; } = default!;
public int LibraryId { get; set; }
public int SeriesId { get; set; }
public string SeriesName { get; set; }
public required string SeriesName { get; set; } = default!;
public DateTime ReadDate { get; set; }
public int ChapterId { get; set; }
public string ChapterNumber { get; set; }
public required string ChapterNumber { get; set; } = default!;
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace API.DTOs.Statistics;
@ -14,17 +13,17 @@ public class ServerStatisticsDto
public long TotalTags { get; set; }
public long TotalPeople { get; set; }
public long TotalReadingTime { get; set; }
public IEnumerable<ICount<SeriesDto>> MostReadSeries { get; set; }
public IEnumerable<ICount<SeriesDto>>? MostReadSeries { get; set; }
/// <summary>
/// Total users who have started/reading/read per series
/// </summary>
public IEnumerable<ICount<SeriesDto>> MostPopularSeries { get; set; }
public IEnumerable<ICount<UserDto>> MostActiveUsers { get; set; }
public IEnumerable<ICount<LibraryDto>> MostActiveLibraries { get; set; }
public IEnumerable<ICount<SeriesDto>>? MostPopularSeries { get; set; }
public IEnumerable<ICount<UserDto>>? MostActiveUsers { get; set; }
public IEnumerable<ICount<LibraryDto>>? MostActiveLibraries { get; set; }
/// <summary>
/// Last 5 Series read
/// </summary>
public IEnumerable<SeriesDto> RecentlyRead { get; set; }
public IEnumerable<SeriesDto>? RecentlyRead { get; set; }
}

View file

@ -1,11 +1,9 @@
using System.Collections.Generic;
namespace API.DTOs.Statistics;
namespace API.DTOs.Statistics;
public class TopReadDto
{
public int UserId { get; set; }
public string Username { get; set; }
public string? Username { get; set; } = default!;
/// <summary>
/// Amount of time read on Comic libraries
/// </summary>

View file

@ -20,6 +20,6 @@ public class UserReadStatistics
public long ChaptersRead { get; set; }
public DateTime LastActive { get; set; }
public double AvgHoursPerWeekSpentReading { get; set; }
public IEnumerable<StatCount<float>> PercentReadPerLibrary { get; set; }
public IEnumerable<StatCount<float>>? PercentReadPerLibrary { get; set; }
}

View file

@ -7,9 +7,9 @@ public class FileFormatDto
/// <summary>
/// The extension with the ., in lowercase
/// </summary>
public string Extension { get; set; }
public required string Extension { get; set; }
/// <summary>
/// Format of extension
/// </summary>
public MangaFormat Format { get; set; }
public required MangaFormat Format { get; set; }
}

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using API.Entities.Enums;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace API.DTOs.Stats;
@ -12,8 +11,8 @@ public class ServerInfoDto
/// <summary>
/// Unique Id that represents a unique install
/// </summary>
public string InstallId { get; set; }
public string Os { get; set; }
public required string InstallId { get; set; }
public required string Os { get; set; }
/// <summary>
/// If the Kavita install is using Docker
/// </summary>
@ -21,11 +20,11 @@ public class ServerInfoDto
/// <summary>
/// Version of .NET instance is running
/// </summary>
public string DotnetVersion { get; set; }
public required string DotnetVersion { get; set; }
/// <summary>
/// Version of Kavita
/// </summary>
public string KavitaVersion { get; set; }
public required string KavitaVersion { get; set; }
/// <summary>
/// Number of Cores on the instance
/// </summary>
@ -42,7 +41,7 @@ public class ServerInfoDto
/// The site theme the install is using
/// </summary>
/// <remarks>Introduced in v0.5.2</remarks>
public string ActiveSiteTheme { get; set; }
public string? ActiveSiteTheme { get; set; }
/// <summary>
/// The reading mode the main user has as a preference
/// </summary>
@ -124,22 +123,22 @@ public class ServerInfoDto
/// A list of background colors set on the instance
/// </summary>
/// <remarks>Introduced in v0.6.0</remarks>
public IEnumerable<string> MangaReaderBackgroundColors { get; set; }
public required IEnumerable<string> MangaReaderBackgroundColors { get; set; }
/// <summary>
/// A list of Page Split defaults being used on the instance
/// </summary>
/// <remarks>Introduced in v0.6.0</remarks>
public IEnumerable<PageSplitOption> MangaReaderPageSplittingModes { get; set; }
public required IEnumerable<PageSplitOption> MangaReaderPageSplittingModes { get; set; }
/// <summary>
/// A list of Layout Mode defaults being used on the instance
/// </summary>
/// <remarks>Introduced in v0.6.0</remarks>
public IEnumerable<LayoutMode> MangaReaderLayoutModes { get; set; }
public required IEnumerable<LayoutMode> MangaReaderLayoutModes { get; set; }
/// <summary>
/// A list of file formats existing in the instance
/// </summary>
/// <remarks>Introduced in v0.6.0</remarks>
public IEnumerable<FileFormatDto> FileFormats { get; set; }
public required IEnumerable<FileFormatDto> FileFormats { get; set; }
/// <summary>
/// If there is at least one user that is using an age restricted profile on the instance
/// </summary>

View file

@ -5,9 +5,9 @@ public class DirectoryDto
/// <summary>
/// Name of the directory
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = default!;
/// <summary>
/// Full Directory Path
/// </summary>
public string FullPath { get; set; }
public string FullPath { get; set; } = default!;
}

View file

@ -14,12 +14,12 @@ public class SiteThemeDto : IEntityDate
/// <summary>
/// Name of the Theme
/// </summary>
public string Name { get; set; }
public required string Name { get; set; }
/// <summary>
/// File path to the content. Stored under <see cref="DirectoryService.SiteThemeDirectory"/>.
/// Must be a .css file
/// </summary>
public string FileName { get; set; }
public required string FileName { get; set; }
/// <summary>
/// Only one theme can have this. Will auto-set this as default for new user accounts
/// </summary>

View file

@ -8,24 +8,24 @@ public class UpdateNotificationDto
/// <summary>
/// Current installed Version
/// </summary>
public string CurrentVersion { get; init; }
public required string CurrentVersion { get; init; }
/// <summary>
/// Semver of the release version
/// <example>0.4.3</example>
/// </summary>
public string UpdateVersion { get; init; }
public required string UpdateVersion { get; init; }
/// <summary>
/// Release body in HTML
/// </summary>
public string UpdateBody { get; init; }
public required string UpdateBody { get; init; }
/// <summary>
/// Title of the release
/// </summary>
public string UpdateTitle { get; init; }
public required string UpdateTitle { get; init; }
/// <summary>
/// Github Url
/// </summary>
public string UpdateUrl { get; init; }
public required string UpdateUrl { get; init; }
/// <summary>
/// If this install is within Docker
/// </summary>
@ -37,5 +37,5 @@ public class UpdateNotificationDto
/// <summary>
/// Date of the publish
/// </summary>
public string PublishDate { get; init; }
public required string PublishDate { get; init; }
}

View file

@ -9,11 +9,11 @@ public class UpdateLibraryDto
[Required]
public int Id { get; init; }
[Required]
public string Name { get; init; }
public required string Name { get; init; }
[Required]
public LibraryType Type { get; set; }
[Required]
public IEnumerable<string> Folders { get; init; }
public required IEnumerable<string> Folders { get; init; }
[Required]
public bool FolderWatching { get; init; }
[Required]

View file

@ -4,6 +4,6 @@ namespace API.DTOs;
public class UpdateLibraryForUserDto
{
public string Username { get; init; }
public IEnumerable<LibraryDto> SelectedLibraries { get; init; }
public required string Username { get; init; }
public required IEnumerable<LibraryDto> SelectedLibraries { get; init; } = new List<LibraryDto>();
}

View file

@ -4,6 +4,6 @@ namespace API.DTOs;
public class UpdateRbsDto
{
public string Username { get; init; }
public IList<string> Roles { get; init; }
public required string Username { get; init; }
public IList<string>? Roles { get; init; }
}

View file

@ -3,9 +3,9 @@
public class UpdateSeriesDto
{
public int Id { get; init; }
public string Name { get; init; }
public string LocalizedName { get; init; }
public string SortName { get; init; }
public required string Name { get; init; }
public string? LocalizedName { get; init; }
public string? SortName { get; init; }
public bool CoverImageLocked { get; set; }
public bool NameLocked { get; set; }

View file

@ -5,6 +5,6 @@ namespace API.DTOs;
public class UpdateSeriesMetadataDto
{
public SeriesMetadataDto SeriesMetadata { get; set; }
public ICollection<CollectionTagDto> CollectionTags { get; set; }
public SeriesMetadataDto SeriesMetadata { get; set; } = default!;
public ICollection<CollectionTagDto> CollectionTags { get; set; } = default!;
}

View file

@ -7,5 +7,5 @@ public class UpdateSeriesRatingDto
public int SeriesId { get; init; }
public int UserRating { get; init; }
[MaxLength(1000)]
public string UserReview { get; init; }
public string? UserReview { get; init; }
}

View file

@ -5,9 +5,9 @@ public class UploadFileDto
/// <summary>
/// Id of the Entity
/// </summary>
public int Id { get; set; }
public required int Id { get; set; }
/// <summary>
/// Base Url encoding of the file to upload from (can be null)
/// </summary>
public string Url { get; set; }
public required string Url { get; set; }
}

View file

@ -1,9 +1,12 @@
namespace API.DTOs.Uploads;
using System.ComponentModel.DataAnnotations;
namespace API.DTOs.Uploads;
public class UploadUrlDto
{
/// <summary>
/// External url
/// </summary>
public string Url { get; set; }
[Required]
public required string Url { get; set; }
}

View file

@ -1,16 +1,15 @@

using API.DTOs.Account;
using API.Entities.Enums;
namespace API.DTOs;
public class UserDto
{
public string Username { get; init; }
public string Email { get; init; }
public string Token { get; set; }
public string RefreshToken { get; set; }
public string ApiKey { get; init; }
public UserPreferencesDto Preferences { get; set; }
public AgeRestrictionDto AgeRestriction { get; init; }
public string Username { get; init; } = null!;
public string Email { get; init; } = null!;
public string Token { get; set; } = null!;
public string? RefreshToken { get; set; }
public string? ApiKey { get; init; }
public UserPreferencesDto? Preferences { get; set; }
public AgeRestrictionDto? AgeRestriction { get; init; }
}

View file

@ -80,7 +80,8 @@ public class UserPreferencesDto
/// Book Reader Option: Maps to the default Kavita font-family (inherit) or an override
/// </summary>
[Required]
public string BookReaderFontFamily { get; set; }
public string BookReaderFontFamily { get; set; } = null!;
/// <summary>
/// Book Reader Option: Allows tapping on side of screens to paginate
/// </summary>
@ -96,9 +97,10 @@ public class UserPreferencesDto
/// UI Site Global Setting: The UI theme the user should use.
/// </summary>
/// <remarks>Should default to Dark</remarks>
public SiteTheme Theme { get; set; }
[Required]
public string BookReaderThemeName { get; set; }
public SiteTheme? Theme { get; set; }
[Required] public string BookReaderThemeName { get; set; } = null!;
[Required]
public BookPageLayoutMode BookReaderLayoutMode { get; set; }
/// <summary>

View file

@ -11,14 +11,15 @@ public class VolumeDto : IHasReadTimeEstimate
public int Id { get; set; }
/// <inheritdoc cref="Volume.Number"/>
public int Number { get; set; }
/// <inheritdoc cref="Volume.Name"/>
public string Name { get; set; }
public string Name { get; set; } = default!;
public int Pages { get; set; }
public int PagesRead { get; set; }
public DateTime LastModified { get; set; }
public DateTime Created { get; set; }
public int SeriesId { get; set; }
public ICollection<ChapterDto> Chapters { get; set; }
public ICollection<ChapterDto> Chapters { get; set; } = new List<ChapterDto>();
/// <inheritdoc cref="IHasReadTimeEstimate.MinHoursToRead"/>
public int MinHoursToRead { get; set; }
/// <inheritdoc cref="IHasReadTimeEstimate.MaxHoursToRead"/>

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace API.DTOs.WantToRead;
@ -10,5 +11,5 @@ public class UpdateWantToReadDto
/// <summary>
/// List of Series Ids that will be Added/Removed
/// </summary>
public IList<int> SeriesIds { get; set; }
public IList<int> SeriesIds { get; set; } = ArraySegment<int>.Empty;
}