diff options
| author | Niels van Velzen <git@ndat.nl> | 2022-10-28 22:39:00 -0400 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2022-10-28 22:39:00 -0400 |
| commit | 21c19bab41b95f5d78d72071ed854ed4bcf5aaab (patch) | |
| tree | 74f3fdee58e8f93f22354614681fc6ec84b908bd | |
| parent | f9221c9a64d626ef7426ed447e67091c28dc20e4 (diff) | |
Backport pull request #8611 from jellyfin/release-10.8.z
Fix TranscodeReasons type in OpenAPI output
Original-merge: c86d5838becf19ba59303d47dac4a62836b44ea2
Merged-by: Claus Vium <cvium@users.noreply.github.com>
Backported-by: Joshua M. Boniface <joshua@boniface.me>
| -rw-r--r-- | Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs | 14 | ||||
| -rw-r--r-- | Jellyfin.Server/Filters/AdditionalModelFilter.cs | 11 |
2 files changed, 20 insertions, 5 deletions
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index 66fa3bc31..f74152405 100644 --- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs @@ -434,11 +434,15 @@ namespace Jellyfin.Server.Extensions options.MapType<TranscodeReason>(() => new OpenApiSchema { - Type = "string", - Enum = Enum.GetNames<TranscodeReason>() - .Select(e => new OpenApiString(e)) - .Cast<IOpenApiAny>() - .ToArray() + Type = "array", + Items = new OpenApiSchema + { + Reference = new OpenApiReference + { + Id = nameof(TranscodeReason), + Type = ReferenceType.Schema, + } + } }); // Swashbuckle doesn't use JsonOptions to describe responses, so we need to manually describe it. diff --git a/Jellyfin.Server/Filters/AdditionalModelFilter.cs b/Jellyfin.Server/Filters/AdditionalModelFilter.cs index 487948f81..645696e31 100644 --- a/Jellyfin.Server/Filters/AdditionalModelFilter.cs +++ b/Jellyfin.Server/Filters/AdditionalModelFilter.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Jellyfin.Extensions; using Jellyfin.Server.Migrations; using MediaBrowser.Common.Plugins; @@ -8,6 +9,7 @@ using MediaBrowser.Model.ApiClient; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Session; using MediaBrowser.Model.SyncPlay; +using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; @@ -56,6 +58,15 @@ namespace Jellyfin.Server.Filters context.SchemaGenerator.GenerateSchema(configuration.ConfigurationType, context.SchemaRepository); } + + context.SchemaRepository.AddDefinition(nameof(TranscodeReason), new OpenApiSchema + { + Type = "string", + Enum = Enum.GetNames<TranscodeReason>() + .Select(e => new OpenApiString(e)) + .Cast<IOpenApiAny>() + .ToArray() + }); } } } |
