From 3b8978c86fa2e28ab81be4d3276d21784f528b63 Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Sun, 14 Apr 2024 06:48:25 +0200 Subject: [PATCH] tweak: use "snake_case" for API response fields --- BeatTogether.Status.Api.csproj | 1 + Program.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/BeatTogether.Status.Api.csproj b/BeatTogether.Status.Api.csproj index 6ee79b5..cf6d384 100644 --- a/BeatTogether.Status.Api.csproj +++ b/BeatTogether.Status.Api.csproj @@ -8,6 +8,7 @@ + diff --git a/Program.cs b/Program.cs index 5a82d52..7c34e5d 100644 --- a/Program.cs +++ b/Program.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Serialization; namespace BeatTogether.Status.Api { @@ -24,6 +25,13 @@ public static IHostBuilder CreateHostBuilder(string[] args) => .Configure(hostBuilderContext.Configuration.GetSection("Status")) .Configure(hostBuilderContext.Configuration.GetSection("Quickplay")) .AddControllers() + .AddNewtonsoftJson(options => + { + options.SerializerSettings.ContractResolver = new DefaultContractResolver + { + NamingStrategy = new SnakeCaseNamingStrategy() + }; + }) ) .Configure(applicationBuilder => applicationBuilder