Skip to content

Commit

Permalink
add constants for json setting names
Browse files Browse the repository at this point in the history
  • Loading branch information
HauklandJ committed Oct 3, 2024
1 parent 5f02345 commit f1d1ace
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ internal JsonSettingsNameAttribute(string name)

internal string Name { get; }
}

internal static class JsonSettingNames
{
internal const string ALTINN_API = "AltinnApi";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
3 changes: 2 additions & 1 deletion src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f1d1ace

Please sign in to comment.