diff --git a/src/Altinn.App.Core/Models/ApplicationMetadata.cs b/src/Altinn.App.Core/Models/ApplicationMetadata.cs index 24beaf62e..db28abbf0 100644 --- a/src/Altinn.App.Core/Models/ApplicationMetadata.cs +++ b/src/Altinn.App.Core/Models/ApplicationMetadata.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Altinn.Platform.Storage.Interface.Models; using Newtonsoft.Json; @@ -57,7 +58,13 @@ public ApplicationMetadata(string id) /// [JsonProperty(PropertyName = "logo")] public Logo? Logo { get; set; } - + + /// + /// Frontend sometimes need to have knowledge of the nuget package version for backwards compatibility + /// + [JsonProperty(PropertyName = "altinnNugetVersion")] + public string AltinnNugetVersion { get; set; } = typeof(ApplicationMetadata).Assembly!.GetName().Version!.ToString(); + /// /// Holds properties that are not mapped to other properties /// diff --git a/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs b/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs index aefa1244b..84675dd8f 100644 --- a/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs +++ b/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs @@ -1,3 +1,4 @@ +using System.Reflection; using System.Text.Json; using Altinn.App.Core.Configuration; using Altinn.App.Core.Internal.App; @@ -482,8 +483,9 @@ public async Task GetApplicationMetadata_deserialize_serialize_unmapped_properti AppSettings appSettings = GetAppSettings("AppMetadata", "unmapped-properties.applicationmetadata.json"); IAppMetadata appMetadata = SetupAppMedata(Options.Create(appSettings)); var appMetadataObj = await appMetadata.GetApplicationMetadata(); - string serialized = JsonSerializer.Serialize(appMetadataObj, new JsonSerializerOptions { WriteIndented = true }); + string serialized = JsonSerializer.Serialize(appMetadataObj, new JsonSerializerOptions { WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping }); string expected = File.ReadAllText(Path.Join(appBasePath, "AppMetadata", "unmapped-properties.applicationmetadata.expected.json")); + expected = expected.Replace("--AltinnNugetVersion--", typeof(ApplicationMetadata).Assembly!.GetName().Version!.ToString()); serialized.Should().Be(expected); } diff --git a/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/unmapped-properties.applicationmetadata.expected.json b/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/unmapped-properties.applicationmetadata.expected.json index de16c54b3..88b4be5b3 100644 --- a/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/unmapped-properties.applicationmetadata.expected.json +++ b/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/unmapped-properties.applicationmetadata.expected.json @@ -10,6 +10,7 @@ "Show": "select-instance" }, "Logo": null, + "AltinnNugetVersion": "--AltinnNugetVersion--", "VersionId": null, "Org": "tdd", "Title": {