The Free Software Media System - Server Backend & API
clean up output formatters
crobibero2ca8d31b20d2
diff --git a/Jellyfin.Api/BaseJellyfinApiController.cs b/Jellyfin.Api/BaseJellyfinApiController.csindex a34f9eb62f..6288fb7e34 100644--- a/Jellyfin.Api/BaseJellyfinApiController.cs+++ b/Jellyfin.Api/BaseJellyfinApiController.cs@@ -8,7 +8,10 @@ namespace Jellyfin.Api/// </summary>[ApiController][Route("[controller]")]- [Produces(MediaTypeNames.Application.Json)]+ [Produces(+ MediaTypeNames.Application.Json,+ MediaTypeNames.Application.Json + "; profile=\"CamelCase\"",+ MediaTypeNames.Application.Json + "; profile=\"PascalCase\"")]public class BaseJellyfinApiController : ControllerBase{}diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.csindex 2e2bfea684..c933a298e3 100644--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs@@ -150,6 +150,10 @@ namespace Jellyfin.Server.Extensions.AddMvc(opts =>{opts.UseGeneralRoutePrefix(baseUrl);++ // Allow requester to change between camelCase and PascalCase+ opts.RespectBrowserAcceptHeader = true;+opts.OutputFormatters.Insert(0, new CamelCaseJsonProfileFormatter());opts.OutputFormatters.Insert(0, new PascalCaseJsonProfileFormatter());diff --git a/Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs b/Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.csindex 9b347ae2c2..cac89416eb 100644--- a/Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs+++ b/Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs@@ -15,7 +15,7 @@ namespace Jellyfin.Server.Formatterspublic CamelCaseJsonProfileFormatter() : base(JsonDefaults.GetCamelCaseOptions()){SupportedMediaTypes.Clear();- SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"CamelCase\""));+ SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json; profile=\"CamelCase\""));}}}diff --git a/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs b/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.csindex 0024708bad..2ba2241561 100644--- a/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs+++ b/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs@@ -1,3 +1,4 @@+using System.Net.Mime;using MediaBrowser.Common.Json;using Microsoft.AspNetCore.Mvc.Formatters;using Microsoft.Net.Http.Headers;@@ -16,8 +17,8 @@ namespace Jellyfin.Server.Formatters{SupportedMediaTypes.Clear();// Add application/json for default formatter- SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));- SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"PascalCase\""));+ SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json));+ SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json; profile=\"PascalCase\""));}}}diff --git a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs b/Jellyfin.Server/Formatters/XmlOutputFormatter.csindex 58319657d6..01d99d7c87 100644--- a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs+++ b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs@@ -16,8 +16,9 @@ namespace Jellyfin.Server.Formatters/// </summary>public XmlOutputFormatter(){+ SupportedMediaTypes.Clear();SupportedMediaTypes.Add(MediaTypeNames.Text.Xml);- SupportedMediaTypes.Add("text/xml;charset=UTF-8");+SupportedEncodings.Add(Encoding.UTF8);SupportedEncodings.Add(Encoding.Unicode);}