clean up output formatters

This commit is contained in:
crobibero 2020-08-20 11:17:27 -06:00
parent 634ee2d1e9
commit 2ca8d31b20
5 changed files with 14 additions and 5 deletions

View File

@ -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
{
}

View File

@ -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());

View File

@ -1,3 +1,4 @@
using System.Net.Mime;
using MediaBrowser.Common.Json;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Net.Http.Headers;
@ -16,7 +17,7 @@ namespace Jellyfin.Server.Formatters
{
SupportedMediaTypes.Clear();
// Add application/json for default formatter
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json));
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json; profile=\"PascalCase\""));
}
}

View File

@ -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);
}