Update XML-Documentation with Mediatype

This commit is contained in:
Glax 2025-03-07 14:46:15 +01:00
parent 6c5bc3685e
commit 3a8b400851
7 changed files with 55 additions and 62 deletions

View File

@ -8,7 +8,6 @@ namespace API.Controllers;
[ApiVersion(2)]
[ApiController]
[Produces("application/json")]
[Route("v{version:apiVersion}/[controller]")]
public class JobController(PgsqlContext context) : Controller
{
@ -17,7 +16,7 @@ public class JobController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<Job[]>(Status200OK)]
[ProducesResponseType<Job[]>(Status200OK, "application/json")]
public IActionResult GetAllJobs()
{
Job[] ret = context.Jobs.ToArray();
@ -30,7 +29,7 @@ public class JobController(PgsqlContext context) : Controller
/// <param name="ids">Array of Job-IDs</param>
/// <response code="200"></response>
[HttpPost("WithIDs")]
[ProducesResponseType<Job[]>(Status200OK)]
[ProducesResponseType<Job[]>(Status200OK, "application/json")]
public IActionResult GetJobs([FromBody]string[] ids)
{
Job[] ret = context.Jobs.Where(job => ids.Contains(job.JobId)).ToArray();
@ -43,7 +42,7 @@ public class JobController(PgsqlContext context) : Controller
/// <param name="state">Requested Job-State</param>
/// <response code="200"></response>
[HttpGet("State/{state}")]
[ProducesResponseType<Job[]>(Status200OK)]
[ProducesResponseType<Job[]>(Status200OK, "application/json")]
public IActionResult GetJobsInState(JobState state)
{
Job[] jobsInState = context.Jobs.Where(job => job.state == state).ToArray();
@ -56,7 +55,7 @@ public class JobController(PgsqlContext context) : Controller
/// <param name="type">Requested Job-Type</param>
/// <response code="200"></response>
[HttpGet("Type/{type}")]
[ProducesResponseType<Job[]>(Status200OK)]
[ProducesResponseType<Job[]>(Status200OK, "application/json")]
public IActionResult GetJobsOfType(JobType type)
{
Job[] jobsOfType = context.Jobs.Where(job => job.JobType == type).ToArray();
@ -70,7 +69,7 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="404">Job with ID could not be found</response>
[HttpGet("{id}")]
[ProducesResponseType<Job>(Status200OK)]
[ProducesResponseType<Job>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
public IActionResult GetJob(string id)
{
@ -91,7 +90,7 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="500">Error during Database Operation</response>
[HttpPut("NewDownloadChapterJob/{mangaId}")]
[ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateNewDownloadChapterJob(string mangaId, [FromBody]ulong recurrenceTime)
{
Job job = new DownloadNewChaptersJob(recurrenceTime, mangaId);
@ -106,7 +105,7 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="500">Error during Database Operation</response>
[HttpPut("DownloadSingleChapterJob/{chapterId}")]
[ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateNewDownloadChapterJob(string chapterId)
{
Job job = new DownloadSingleChapterJob(chapterId);
@ -121,7 +120,7 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="500">Error during Database Operation</response>
[HttpPut("UpdateMetadataJob/{mangaId}")]
[ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateUpdateMetadataJob(string mangaId)
{
Job job = new UpdateMetadataJob(0, mangaId);
@ -135,7 +134,7 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="500">Error during Database Operation</response>
[HttpPut("UpdateMetadataJob")]
[ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateUpdateAllMetadataJob()
{
List<string> ids = context.Manga.Select(m => m.MangaId).ToList();
@ -174,9 +173,9 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="404">Job could not be found</response>
/// <response code="500">Error during Database Operation</response>
[HttpDelete("{id}")]
[ProducesResponseType<string[]>(Status200OK)]
[ProducesResponseType<string[]>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult DeleteJob(string id)
{
try
@ -216,10 +215,10 @@ public class JobController(PgsqlContext context) : Controller
/// <response code="404">Job with ID not found</response>
/// <response code="500">Error during Database Operation</response>
[HttpPatch("{id}/")]
[ProducesResponseType<Job>(Status202Accepted)]
[ProducesResponseType<Job>(Status202Accepted, "application/json")]
[ProducesResponseType(Status400BadRequest)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult ModifyJob(string id, [FromBody]ModifyJobRecord modifyJobRecord)
{
try
@ -252,7 +251,7 @@ public class JobController(PgsqlContext context) : Controller
[ProducesResponseType(Status202Accepted)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status409Conflict)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult StartJob(string id)
{
Job? ret = context.Jobs.Find(id);

View File

@ -8,7 +8,6 @@ namespace API.Controllers;
[ApiVersion(2)]
[ApiController]
[Produces("application/json")]
[Route("v{v:apiVersion}/[controller]")]
public class LibraryConnectorController(PgsqlContext context) : Controller
{
@ -17,7 +16,7 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<LibraryConnector[]>(Status200OK)]
[ProducesResponseType<LibraryConnector[]>(Status200OK, "application/json")]
public IActionResult GetAllConnectors()
{
LibraryConnector[] connectors = context.LibraryConnectors.ToArray();
@ -31,7 +30,7 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="404">Connector with ID not found.</response>
[HttpGet("{id}")]
[ProducesResponseType<LibraryConnector>(Status200OK)]
[ProducesResponseType<LibraryConnector>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
public IActionResult GetConnector(string id)
{
@ -47,11 +46,11 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
/// Creates a new Library-Connector
/// </summary>
/// <param name="libraryConnector">Library-Connector</param>
/// <response code="200"></response>
/// <response code="201"></response>
/// <response code="500">Error during Database Operation</response>
[HttpPut]
[ProducesResponseType(Status200OK)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType(Status201Created)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateConnector([FromBody]LibraryConnector libraryConnector)
{
try
@ -76,20 +75,18 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
[HttpDelete("{id}")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult DeleteConnector(string id)
{
try
{
LibraryConnector? ret = context.LibraryConnectors.Find(id);
switch (ret is not null)
{
case true:
context.Remove(ret);
context.SaveChanges();
return Ok();
case false: return NotFound();
}
if (ret is null)
return NotFound();
context.Remove(ret);
context.SaveChanges();
return Ok();
}
catch (Exception e)
{

View File

@ -8,7 +8,6 @@ namespace API.Controllers;
[ApiVersion(2)]
[ApiController]
[Produces("application/json")]
[Route("v{v:apiVersion}")]
public class MangaConnectorController(PgsqlContext context) : Controller
{
@ -17,7 +16,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<MangaConnector[]>(Status200OK)]
[ProducesResponseType<MangaConnector[]>(Status200OK, "application/json")]
public IActionResult GetConnectors()
{
MangaConnector[] connectors = context.MangaConnectors.ToArray();
@ -29,7 +28,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet("enabled")]
[ProducesResponseType<MangaConnector[]>(Status200OK)]
[ProducesResponseType<MangaConnector[]>(Status200OK, "application/json")]
public IActionResult GetEnabledConnectors()
{
MangaConnector[] connectors = context.MangaConnectors.Where(c => c.Enabled == true).ToArray();
@ -41,7 +40,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet("disabled")]
[ProducesResponseType<MangaConnector[]>(Status200OK)]
[ProducesResponseType<MangaConnector[]>(Status200OK, "application/json")]
public IActionResult GetDisabledConnectors()
{
MangaConnector[] connectors = context.MangaConnectors.Where(c => c.Enabled == false).ToArray();
@ -55,9 +54,11 @@ public class MangaConnectorController(PgsqlContext context) : Controller
/// <param name="enabled">Set true to enable</param>
/// <response code="200"></response>
/// <response code="404">Connector with ID not found.</response>
/// <response code="500">Error during Database Operation</response>
[HttpPatch("{id}/SetEnabled/{enabled}")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult SetEnabled(string id, bool enabled)
{
try

View File

@ -12,7 +12,6 @@ namespace API.Controllers;
[ApiVersion(2)]
[ApiController]
[Produces("application/json")]
[Route("v{v:apiVersion}/[controller]")]
public class MangaController(PgsqlContext context) : Controller
{
@ -21,7 +20,7 @@ public class MangaController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<Manga[]>(Status200OK)]
[ProducesResponseType<Manga[]>(Status200OK, "application/json")]
public IActionResult GetAllManga()
{
Manga[] ret = context.Manga.ToArray();
@ -34,7 +33,7 @@ public class MangaController(PgsqlContext context) : Controller
/// <param name="ids">Array of Manga-IDs</param>
/// <response code="200"></response>
[HttpPost("WithIDs")]
[ProducesResponseType<Manga[]>(Status200OK)]
[ProducesResponseType<Manga[]>(Status200OK, "application/json")]
public IActionResult GetManga([FromBody]string[] ids)
{
Manga[] ret = context.Manga.Where(m => ids.Contains(m.MangaId)).ToArray();
@ -48,7 +47,7 @@ public class MangaController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="404">Manga with ID not found</response>
[HttpGet("{id}")]
[ProducesResponseType<Manga>(Status200OK)]
[ProducesResponseType<Manga>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
public IActionResult GetManga(string id)
{
@ -68,7 +67,7 @@ public class MangaController(PgsqlContext context) : Controller
[HttpDelete("{id}")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult DeleteManga(string id)
{
try
@ -97,8 +96,7 @@ public class MangaController(PgsqlContext context) : Controller
/// <response code="400">The formatting-request was invalid</response>
/// <response code="404">Manga with ID not found</response>
[HttpPost("{id}/Cover")]
[Produces("image/jpeg")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType<byte[]>(Status200OK,"image/jpeg")]
[ProducesResponseType(Status204NoContent)]
[ProducesResponseType(Status400BadRequest)]
[ProducesResponseType(Status404NotFound)]
@ -135,7 +133,7 @@ public class MangaController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="404">Manga with ID not found</response>
[HttpGet("{id}/Chapters")]
[ProducesResponseType<Chapter[]>(Status200OK)]
[ProducesResponseType<Chapter[]>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
public IActionResult GetChapters(string id)
{
@ -156,10 +154,10 @@ public class MangaController(PgsqlContext context) : Controller
/// <response code="404">Manga with ID not found.</response>
/// <response code="500">Could not retrieve the maximum chapter-number</response>
[HttpGet("{id}/Chapter/Latest")]
[ProducesResponseType<Chapter>(Status200OK)]
[ProducesResponseType<Chapter>(Status200OK, "application/json")]
[ProducesResponseType(Status204NoContent)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult GetLatestChapter(string id)
{
Manga? m = context.Manga.Find(id);
@ -184,7 +182,7 @@ public class MangaController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="404">Manga with ID not found.</response>
[HttpPatch("{id}/IgnoreChaptersBefore")]
[ProducesResponseType<float>(Status200OK)]
[ProducesResponseType<float>(Status200OK, "text/plain")]
[ProducesResponseType(Status404NotFound)]
public IActionResult IgnoreChaptersBefore(string id)
{

View File

@ -17,7 +17,7 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
[ProducesResponseType<NotificationConnector[]>(Status200OK, "application/json")]
public IActionResult GetAllConnectors()
{
NotificationConnector[] ret = context.NotificationConnectors.ToArray();
@ -31,7 +31,7 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="404">NotificationConnector with ID not found</response>
[HttpGet("{id}")]
[ProducesResponseType<NotificationConnector>(Status200OK)]
[ProducesResponseType<NotificationConnector>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
public IActionResult GetConnector(string id)
{
@ -50,8 +50,8 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
/// <response code="201"></response>
/// <response code="500">Error during Database Operation</response>
[HttpPut]
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<NotificationConnector[]>(Status200OK, "application/json")]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult CreateConnector([FromBody]NotificationConnector notificationConnector)
{
try
@ -76,7 +76,7 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
[HttpDelete("{id}")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult DeleteConnector(string id)
{
try

View File

@ -10,7 +10,6 @@ namespace API.Controllers;
[ApiVersion(2)]
[ApiController]
[Produces("application/json")]
[Route("v{v:apiVersion}/[controller]")]
public class SearchController(PgsqlContext context) : Controller
{
@ -22,8 +21,8 @@ public class SearchController(PgsqlContext context) : Controller
/// <response code="200"></response>
/// <response code="500">Error during Database Operation</response>
[HttpPost("{name}")]
[ProducesResponseType<Manga[]>(Status200OK)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<Manga[]>(Status200OK, "application/json")]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult SearchMangaGlobal(string name)
{
List<(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)> allManga = new();
@ -57,10 +56,10 @@ public class SearchController(PgsqlContext context) : Controller
/// <response code="406">MangaConnector with ID is disabled</response>
/// <response code="500">Error during Database Operation</response>
[HttpPost("{id}/{name}")]
[ProducesResponseType<Manga[]>(Status200OK)]
[ProducesResponseType<Manga[]>(Status200OK, "application/json")]
[ProducesResponseType(Status404NotFound)]
[ProducesResponseType(Status406NotAcceptable)]
[ProducesResponseType<string>(Status500InternalServerError)]
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public IActionResult SearchManga(string id, string name)
{
MangaConnector? connector = context.MangaConnectors.Find(id);

View File

@ -9,7 +9,6 @@ namespace API.Controllers;
[ApiVersion(2)]
[ApiController]
[Produces("application/json")]
[Route("v{v:apiVersion}/[controller]")]
public class SettingsController(PgsqlContext context) : Controller
{
@ -18,7 +17,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet]
[ProducesResponseType<JsonObject>(StatusCodes.Status200OK)]
[ProducesResponseType<string>(StatusCodes.Status200OK, "application/json")]
public IActionResult GetSettings()
{
return Ok(TrangaSettings.Serialize());
@ -29,7 +28,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet("UserAgent")]
[ProducesResponseType<string>(Status200OK)]
[ProducesResponseType<string>(Status200OK, "text/plain")]
public IActionResult GetUserAgent()
{
return Ok(TrangaSettings.userAgent);
@ -64,7 +63,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200"></response>
[HttpGet("RequestLimits")]
[ProducesResponseType<Dictionary<RequestType,int>>(Status200OK)]
[ProducesResponseType<Dictionary<RequestType,int>>(Status200OK, "application/json")]
public IActionResult GetRequestLimits()
{
return Ok(TrangaSettings.requestLimits);
@ -97,7 +96,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200">JPEG compression-level as Integer</response>
[HttpGet("ImageCompression")]
[ProducesResponseType<int>(Status200OK)]
[ProducesResponseType<int>(Status200OK, "text/plain")]
public IActionResult GetImageCompression()
{
return Ok(TrangaSettings.compression);
@ -125,7 +124,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// </summary>
/// <response code="200">True if enabled</response>
[HttpGet("BWImages")]
[ProducesResponseType<bool>(Status200OK)]
[ProducesResponseType<bool>(Status200OK, "text/plain")]
public IActionResult GetBwImagesToggle()
{
return Ok(TrangaSettings.bwImages);
@ -150,7 +149,7 @@ public class SettingsController(PgsqlContext context) : Controller
/// <remarks>April Fools Mode disables all downloads on April 1st</remarks>
/// <response code="200">True if enabled</response>
[HttpGet("AprilFoolsMode")]
[ProducesResponseType<bool>(Status200OK)]
[ProducesResponseType<bool>(Status200OK, "text/plain")]
public IActionResult GetAprilFoolsMode()
{
return Ok(TrangaSettings.aprilFoolsMode);