Parcourir la source

add camelCase formatter

crobibero il y a 5 ans
Parent
commit
ad67081840
1 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 21 0
      Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs

+ 21 - 0
Jellyfin.Server/Formatters/CamelCaseJsonProfileFormatter.cs

@@ -0,0 +1,21 @@
+using System.Text.Json;
+using Microsoft.AspNetCore.Mvc.Formatters;
+using Microsoft.Net.Http.Headers;
+
+namespace Jellyfin.Server.Formatters
+{
+    /// <summary>
+    /// Camel Case Json Profile Formatter.
+    /// </summary>
+    public class CamelCaseJsonProfileFormatter : SystemTextJsonOutputFormatter
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CamelCaseJsonProfileFormatter"/> class.
+        /// </summary>
+        public CamelCaseJsonProfileFormatter() : base(new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase })
+        {
+            SupportedMediaTypes.Clear();
+            SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"CamelCase\""));
+        }
+    }
+}