diff --git a/src/NzbDrone.Host/Startup.cs b/src/NzbDrone.Host/Startup.cs index 4bcc75e60..eb18394fc 100644 --- a/src/NzbDrone.Host/Startup.cs +++ b/src/NzbDrone.Host/Startup.cs @@ -158,6 +158,8 @@ namespace NzbDrone.Host { { apikeyQuery, Array.Empty() } }); + + c.DescribeAllParametersInCamelCase(); }); services diff --git a/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs b/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs index b5c9392b8..2091d3cfe 100644 --- a/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs +++ b/src/Sonarr.Api.V3/Blocklist/BlocklistController.cs @@ -23,9 +23,9 @@ namespace Sonarr.Api.V3.Blocklist [HttpGet] [Produces("application/json")] - public PagingResource GetBlocklist() + public PagingResource GetBlocklist([FromQuery] PagingRequestResource paging) { - var pagingResource = Request.ReadPagingResourceFromRequest(); + var pagingResource = new PagingResource(paging); var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending); return pagingSpec.ApplyToPage(_blocklistService.Paged, model => BlocklistResourceMapper.MapToResource(model, _formatCalculator)); diff --git a/src/Sonarr.Api.V3/History/HistoryController.cs b/src/Sonarr.Api.V3/History/HistoryController.cs index cb6075676..b7cf660ca 100644 --- a/src/Sonarr.Api.V3/History/HistoryController.cs +++ b/src/Sonarr.Api.V3/History/HistoryController.cs @@ -61,9 +61,9 @@ namespace Sonarr.Api.V3.History [HttpGet] [Produces("application/json")] - public PagingResource GetHistory(bool includeSeries, bool includeEpisode) + public PagingResource GetHistory([FromQuery] PagingRequestResource paging, bool includeSeries, bool includeEpisode) { - var pagingResource = Request.ReadPagingResourceFromRequest(); + var pagingResource = new PagingResource(paging); var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending); var eventTypeFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "eventType"); diff --git a/src/Sonarr.Api.V3/Logs/LogController.cs b/src/Sonarr.Api.V3/Logs/LogController.cs index 3350bcce3..eb28993f2 100644 --- a/src/Sonarr.Api.V3/Logs/LogController.cs +++ b/src/Sonarr.Api.V3/Logs/LogController.cs @@ -18,9 +18,9 @@ namespace Sonarr.Api.V3.Logs [HttpGet] [Produces("application/json")] - public PagingResource GetLogs() + public PagingResource GetLogs([FromQuery] PagingRequestResource paging) { - var pagingResource = Request.ReadPagingResourceFromRequest(); + var pagingResource = new PagingResource(paging); var pageSpec = pagingResource.MapToPagingSpec(); if (pageSpec.SortKey == "time") diff --git a/src/Sonarr.Api.V3/Wanted/CutoffController.cs b/src/Sonarr.Api.V3/Wanted/CutoffController.cs index b906399b0..47a805829 100644 --- a/src/Sonarr.Api.V3/Wanted/CutoffController.cs +++ b/src/Sonarr.Api.V3/Wanted/CutoffController.cs @@ -29,9 +29,9 @@ namespace Sonarr.Api.V3.Wanted [HttpGet] [Produces("application/json")] - public PagingResource GetCutoffUnmetEpisodes(bool includeSeries = false, bool includeEpisodeFile = false, bool includeImages = false) + public PagingResource GetCutoffUnmetEpisodes([FromQuery] PagingRequestResource paging, bool includeSeries = false, bool includeEpisodeFile = false, bool includeImages = false) { - var pagingResource = Request.ReadPagingResourceFromRequest(); + var pagingResource = new PagingResource(paging); var pagingSpec = new PagingSpec { Page = pagingResource.Page, diff --git a/src/Sonarr.Api.V3/Wanted/MissingController.cs b/src/Sonarr.Api.V3/Wanted/MissingController.cs index 6ed40dda7..c65b52638 100644 --- a/src/Sonarr.Api.V3/Wanted/MissingController.cs +++ b/src/Sonarr.Api.V3/Wanted/MissingController.cs @@ -25,9 +25,9 @@ namespace Sonarr.Api.V3.Wanted [HttpGet] [Produces("application/json")] - public PagingResource GetMissingEpisodes(bool includeSeries = false, bool includeImages = false) + public PagingResource GetMissingEpisodes([FromQuery] PagingRequestResource paging, bool includeSeries = false, bool includeImages = false) { - var pagingResource = Request.ReadPagingResourceFromRequest(); + var pagingResource = new PagingResource(paging); var pagingSpec = new PagingSpec { Page = pagingResource.Page, diff --git a/src/Sonarr.Api.V3/openapi.json b/src/Sonarr.Api.V3/openapi.json index ef261ba3c..f15cc9031 100644 --- a/src/Sonarr.Api.V3/openapi.json +++ b/src/Sonarr.Api.V3/openapi.json @@ -59,25 +59,25 @@ "schema": { "type": "object", "properties": { - "Username": { + "username": { "type": "string" }, - "Password": { + "password": { "type": "string" }, - "RememberMe": { + "rememberMe": { "type": "string" } } }, "encoding": { - "Username": { + "username": { "style": "form" }, - "Password": { + "password": { "style": "form" }, - "RememberMe": { + "rememberMe": { "style": "form" } } @@ -381,6 +381,50 @@ "tags": [ "Blocklist" ], + "parameters": [ + { + "name": "page", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 1 + } + }, + { + "name": "pageSize", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 10 + } + }, + { + "name": "sortKey", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "sortDirection", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SortDirection" + } + }, + { + "name": "filters", + "in": "query", + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PagingResourceFilter" + } + } + } + ], "responses": { "200": { "description": "Success", @@ -1050,6 +1094,48 @@ "Cutoff" ], "parameters": [ + { + "name": "page", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 1 + } + }, + { + "name": "pageSize", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 10 + } + }, + { + "name": "sortKey", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "sortDirection", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SortDirection" + } + }, + { + "name": "filters", + "in": "query", + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PagingResourceFilter" + } + } + }, { "name": "includeSeries", "in": "query", @@ -2220,6 +2306,48 @@ "History" ], "parameters": [ + { + "name": "page", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 1 + } + }, + { + "name": "pageSize", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 10 + } + }, + { + "name": "sortKey", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "sortDirection", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SortDirection" + } + }, + { + "name": "filters", + "in": "query", + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PagingResourceFilter" + } + } + }, { "name": "includeSeries", "in": "query", @@ -3627,6 +3755,50 @@ "tags": [ "Log" ], + "parameters": [ + { + "name": "page", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 1 + } + }, + { + "name": "pageSize", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 10 + } + }, + { + "name": "sortKey", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "sortDirection", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SortDirection" + } + }, + { + "name": "filters", + "in": "query", + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PagingResourceFilter" + } + } + } + ], "responses": { "200": { "description": "Success", @@ -4142,6 +4314,48 @@ "Missing" ], "parameters": [ + { + "name": "page", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 1 + } + }, + { + "name": "pageSize", + "in": "query", + "schema": { + "type": "integer", + "format": "int32", + "default": 10 + } + }, + { + "name": "sortKey", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "sortDirection", + "in": "query", + "schema": { + "$ref": "#/components/schemas/SortDirection" + } + }, + { + "name": "filters", + "in": "query", + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PagingResourceFilter" + } + } + }, { "name": "includeSeries", "in": "query", @@ -4325,21 +4539,21 @@ ], "parameters": [ { - "name": "RenameEpisodes", + "name": "renameEpisodes", "in": "query", "schema": { "type": "boolean" } }, { - "name": "ReplaceIllegalCharacters", + "name": "replaceIllegalCharacters", "in": "query", "schema": { "type": "boolean" } }, { - "name": "ColonReplacementFormat", + "name": "colonReplacementFormat", "in": "query", "schema": { "type": "integer", @@ -4347,7 +4561,7 @@ } }, { - "name": "MultiEpisodeStyle", + "name": "multiEpisodeStyle", "in": "query", "schema": { "type": "integer", @@ -4355,91 +4569,91 @@ } }, { - "name": "StandardEpisodeFormat", + "name": "standardEpisodeFormat", "in": "query", "schema": { "type": "string" } }, { - "name": "DailyEpisodeFormat", + "name": "dailyEpisodeFormat", "in": "query", "schema": { "type": "string" } }, { - "name": "AnimeEpisodeFormat", + "name": "animeEpisodeFormat", "in": "query", "schema": { "type": "string" } }, { - "name": "SeriesFolderFormat", + "name": "seriesFolderFormat", "in": "query", "schema": { "type": "string" } }, { - "name": "SeasonFolderFormat", + "name": "seasonFolderFormat", "in": "query", "schema": { "type": "string" } }, { - "name": "SpecialsFolderFormat", + "name": "specialsFolderFormat", "in": "query", "schema": { "type": "string" } }, { - "name": "IncludeSeriesTitle", + "name": "includeSeriesTitle", "in": "query", "schema": { "type": "boolean" } }, { - "name": "IncludeEpisodeTitle", + "name": "includeEpisodeTitle", "in": "query", "schema": { "type": "boolean" } }, { - "name": "IncludeQuality", + "name": "includeQuality", "in": "query", "schema": { "type": "boolean" } }, { - "name": "ReplaceSpaces", + "name": "replaceSpaces", "in": "query", "schema": { "type": "boolean" } }, { - "name": "Separator", + "name": "separator", "in": "query", "schema": { "type": "string" } }, { - "name": "NumberStyle", + "name": "numberStyle", "in": "query", "schema": { "type": "string" } }, { - "name": "Id", + "name": "id", "in": "query", "schema": { "type": "integer", @@ -4447,7 +4661,7 @@ } }, { - "name": "ResourceName", + "name": "resourceName", "in": "query", "schema": { "type": "string" @@ -7402,7 +7616,7 @@ "type": "array", "items": { "type": "object", - "additionalProperties": { } + "additionalProperties": {} }, "nullable": true } @@ -11628,10 +11842,10 @@ }, "security": [ { - "X-Api-Key": [ ] + "X-Api-Key": [] }, { - "apikey": [ ] + "apikey": [] } ] } \ No newline at end of file diff --git a/src/Sonarr.Http/PagingResource.cs b/src/Sonarr.Http/PagingResource.cs index d1c0a6eb7..dc10003a3 100644 --- a/src/Sonarr.Http/PagingResource.cs +++ b/src/Sonarr.Http/PagingResource.cs @@ -1,8 +1,20 @@ using System.Collections.Generic; +using System.ComponentModel; using NzbDrone.Core.Datastore; namespace Sonarr.Http { + public class PagingRequestResource + { + [DefaultValue(1)] + public int? Page { get; set; } + [DefaultValue(10)] + public int? PageSize { get; set; } + public string SortKey { get; set; } + public SortDirection? SortDirection { get; set; } + public List Filters { get; set; } + } + public class PagingResource { public int Page { get; set; } @@ -10,8 +22,22 @@ namespace Sonarr.Http public string SortKey { get; set; } public SortDirection SortDirection { get; set; } public List Filters { get; set; } + public int TotalRecords { get; set; } public List Records { get; set; } + + public PagingResource() + { + } + + public PagingResource(PagingRequestResource requestResource) + { + Page = requestResource.Page ?? 1; + PageSize = requestResource.PageSize ?? 10; + SortKey = requestResource.SortKey; + SortDirection = requestResource.SortDirection ?? SortDirection.Descending; + Filters = requestResource.Filters ?? new List(); + } } public static class PagingResourceMapper