diff --git a/src/Altinn.App.Api/Controllers/Attributes/JsonSettingsNameAttribute.cs b/src/Altinn.App.Api/Controllers/Attributes/JsonSettingsNameAttribute.cs index 8511a495a..0e3ad9da9 100644 --- a/src/Altinn.App.Api/Controllers/Attributes/JsonSettingsNameAttribute.cs +++ b/src/Altinn.App.Api/Controllers/Attributes/JsonSettingsNameAttribute.cs @@ -12,3 +12,8 @@ internal JsonSettingsNameAttribute(string name) internal string Name { get; } } + +internal static class JsonSettingNames +{ + internal const string ALTINN_API = "AltinnApi"; +} diff --git a/src/Altinn.App.Api/Controllers/Conventions/AltinnControllerConventions.cs b/src/Altinn.App.Api/Controllers/Conventions/AltinnControllerConventions.cs index 1f7f87ba4..ebb4b3cdd 100644 --- a/src/Altinn.App.Api/Controllers/Conventions/AltinnControllerConventions.cs +++ b/src/Altinn.App.Api/Controllers/Conventions/AltinnControllerConventions.cs @@ -7,6 +7,6 @@ internal class AltinnControllerConventions : IControllerModelConvention { public void Apply(ControllerModel controller) { - controller.Filters.Add(new JsonSettingsNameAttribute("AltinnApi")); + controller.Filters.Add(new JsonSettingsNameAttribute(JsonSettingNames.ALTINN_API)); } } diff --git a/src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.cs b/src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.cs index ddb4ad39e..0cae0cacb 100644 --- a/src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.cs +++ b/src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Altinn.App.Api.Controllers; +using Altinn.App.Api.Controllers.Attributes; using Altinn.App.Api.Controllers.Conventions; using Altinn.App.Api.Helpers; using Altinn.App.Api.Infrastructure.Filters; @@ -50,7 +51,7 @@ public static void AddAltinnAppControllersWithViews(this IServiceCollection serv .AddApplicationPart(typeof(InstancesController).Assembly) .AddXmlSerializerFormatters() .AddJsonOptions( - "AltinnApi", + JsonSettingNames.ALTINN_API, options => { options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;