diff options
| author | Bond-009 <bond.009@outlook.com> | 2020-04-25 11:09:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-25 11:09:38 +0200 |
| commit | 383bc453728684bca187e826ff099493175ba312 (patch) | |
| tree | a6da02b3978e1ef13d6aeb04b56d9dc64e1195de /Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs | |
| parent | a2f19eadf739297cbbc99c9082b0175e8b881054 (diff) | |
| parent | 0765ef8bda4d23e33fde7a1bfe49b5a365c6d28e (diff) | |
Merge pull request #2932 from crobibero/api-casing
Add optional camelCase formatter
Diffstat (limited to 'Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs')
| -rw-r--r-- | Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs b/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs new file mode 100644 index 000000000..675f4c79e --- /dev/null +++ b/Jellyfin.Server/Formatters/PascalCaseJsonProfileFormatter.cs @@ -0,0 +1,23 @@ +using Jellyfin.Server.Models; +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(JsonOptions.PascalCase) + { + SupportedMediaTypes.Clear(); + // Add application/json for default formatter + SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json")); + SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"PascalCase\"")); + } + } +} |
