The Free Software Media System - Server Backend & API
Fix PascalCase
crobiberoc89dc8921ffb
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.csindex 71ef9a69a2..00688074f0 100644--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs@@ -4,6 +4,7 @@ using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy;using Jellyfin.Api.Auth.RequiresElevationPolicy;using Jellyfin.Api.Constants;using Jellyfin.Api.Controllers;+using Jellyfin.Server.Formatters;using Microsoft.AspNetCore.Authentication;using Microsoft.AspNetCore.Authorization;using Microsoft.Extensions.DependencyInjection;@@ -66,6 +67,8 @@ namespace Jellyfin.Server.Extensionsreturn serviceCollection.AddMvc(opts =>{opts.UseGeneralRoutePrefix(baseUrl);+ opts.OutputFormatters.Insert(0, new CamelCaseJsonProfileFormatter());+ opts.OutputFormatters.Insert(0, new PascalCaseJsonProfileFormatter());})// Clear app parts to avoid other assemblies being picked updiff --git a/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs b/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.csnew file mode 100644index 0000000000..2ed006a336--- /dev/null+++ b/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs@@ -0,0 +1,23 @@+using System.Text.Json;+using Microsoft.AspNetCore.Mvc.Formatters;+using Microsoft.Net.Http.Headers;++namespace Jellyfin.Server.Formatters+{+ /// <summary>+ /// Pascal Case Json Profile Formatter.+ /// </summary>+ public class PascalCaseJsonProfileFormatter : SystemTextJsonOutputFormatter+ {+ /// <summary>+ /// Initializes a new instance of the <see cref="PascalCaseJsonProfileFormatter"/> class.+ /// </summary>+ public PascalCaseJsonProfileFormatter() : base(new JsonSerializerOptions { PropertyNamingPolicy = null })+ {+ SupportedMediaTypes.Clear();+ // Add application/json for default formatter+ SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));+ SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"PascalCase\""));+ }+ }+}