From f18ada3e14c1e47fe192ab06062be0d9e8b11c8c Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Thu, 25 Jan 2024 15:16:24 +0000 Subject: [PATCH] Add json enum config so Swagger will display enums as strings --- TramsDataApi/Startup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TramsDataApi/Startup.cs b/TramsDataApi/Startup.cs index 6d6de9b1c..f555d700a 100644 --- a/TramsDataApi/Startup.cs +++ b/TramsDataApi/Startup.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Serialization; using Dfe.Academisation.CorrelationIdMiddleware; namespace TramsDataApi @@ -36,7 +37,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddControllers(); + services.AddControllers().AddJsonOptions(c => {c.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());}); services.AddApiVersioning(); services.AddFeatureManagement();