Fixed: 'includeSeasonImages' parameter to get single series from API

Closes #5971
This commit is contained in:
Bogdan 2023-08-29 05:28:56 +03:00 committed by GitHub
parent f521942301
commit 87b3a305e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 29 deletions

View File

@ -4,6 +4,7 @@ using FluentValidation;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
@ -19,6 +20,7 @@ using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
using Sonarr.Http;
using Sonarr.Http.Extensions;
using Sonarr.Http.REST;
using Sonarr.Http.REST.Attributes;
@ -118,12 +120,40 @@ namespace Sonarr.Api.V3.Series
return seriesResources;
}
[NonAction]
public override ActionResult<SeriesResource> GetResourceByIdWithErrorHandler(int id)
{
return base.GetResourceByIdWithErrorHandler(id);
}
[RestGetById]
[Produces("application/json")]
public ActionResult<SeriesResource> GetResourceByIdWithErrorHandler(int id, [FromQuery] bool includeSeasonImages = false)
{
try
{
return GetSeriesResourceById(id, includeSeasonImages);
}
catch (ModelNotFoundException)
{
return NotFound();
}
}
protected override SeriesResource GetResourceById(int id)
{
var includeSeasonImages = Request?.GetBooleanQueryParameter("includeSeasonImages", false) ?? false;
// Parse IncludeImages and use it
return GetSeriesResourceById(id, includeSeasonImages);
}
private SeriesResource GetSeriesResourceById(int id, bool includeSeasonImages = false)
{
var series = _seriesService.GetSeries(id);
// Parse IncludeImages and use it
return GetSeriesResource(series, false);
return GetSeriesResource(series, includeSeasonImages);
}
[RestPostById]

View File

@ -6090,6 +6090,42 @@
}
},
"/api/v3/series/{id}": {
"get": {
"tags": [
"Series"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "includeSeasonImages",
"in": "query",
"schema": {
"type": "boolean",
"default": false
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SeriesResource"
}
}
}
}
}
},
"put": {
"tags": [
"Series"
@ -6180,34 +6216,6 @@
"description": "Success"
}
}
},
"get": {
"tags": [
"Series"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SeriesResource"
}
}
}
}
}
}
},
"/api/v3/series/editor": {