From 33cf27a22e096d419f28efc402ac0ff428fde441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Fri, 1 Nov 2024 09:47:15 +0100 Subject: [PATCH 1/8] change --- src/Digdir.Domain.Dialogporten.WebApi/Program.cs | 4 +++- .../Common/DialogApplication.cs | 1 - .../V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs index f69497778..7006d2b7b 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs @@ -203,7 +203,9 @@ static void IgnoreEmptyCollections(JsonTypeInfo typeInfo) { foreach (var property in typeInfo.Properties) { - if (property.PropertyType.IsAssignableTo(typeof(ICollection))) + if (property.PropertyType.IsGenericType && + property.PropertyType.IsAssignableTo(typeof(ICollection)) && + property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) { property.ShouldSerialize = (_, val) => val is ICollection collection && collection.Count > 0; } diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Common/DialogApplication.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Common/DialogApplication.cs index e8122c082..77ac51abc 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Common/DialogApplication.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Common/DialogApplication.cs @@ -52,7 +52,6 @@ public async Task InitializeAsync() AssertionOptions.AssertEquivalencyUsing(options => { - //options.ExcludingMissingMembers(); options.Using(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromMicroseconds(1))) .WhenTypeIs(); return options; diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs index 5f5cb4e91..2493b064f 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs @@ -27,7 +27,6 @@ public async Task Get_ReturnsSimpleDialog_WhenDialogExists() response.TryPickT0(out var result, out _).Should().BeTrue(); result.Should().NotBeNull(); result.Should().BeEquivalentTo(createDialogCommand, options => options - .ExcludingMissingMembers() .Excluding(x => x.UpdatedAt) .Excluding(x => x.CreatedAt) .Excluding(x => x.SystemLabel)); @@ -48,7 +47,6 @@ public async Task Get_ReturnsDialog_WhenDialogExists() response.TryPickT0(out var result, out _).Should().BeTrue(); result.Should().NotBeNull(); result.Should().BeEquivalentTo(createCommand, options => options - .ExcludingMissingMembers() .Excluding(x => x.UpdatedAt) .Excluding(x => x.CreatedAt) .Excluding(x => x.SystemLabel)); From 443dfb7640ed9e088f11fcdf346a50e90c12b4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Fri, 1 Nov 2024 11:14:47 +0100 Subject: [PATCH 2/8] test --- tests/k6/tests/serviceowner/dialogSearch.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/k6/tests/serviceowner/dialogSearch.js b/tests/k6/tests/serviceowner/dialogSearch.js index 7d6e318b3..eb98fbfe1 100644 --- a/tests/k6/tests/serviceowner/dialogSearch.js +++ b/tests/k6/tests/serviceowner/dialogSearch.js @@ -45,7 +45,7 @@ export default function () { let titleForLastItem = uuidv4(); let updatedAfter = (new Date()).toISOString(); // We use this on all tests to avoid clashing with unrelated dialogs let defaultFilter = "?UpdatedAfter=" + updatedAfter; - + describe('Arrange: Create some dialogs to test against', () => { for (let i = 0; i < 20; i++) { @@ -207,7 +207,9 @@ export default function () { let r = getSO('dialogs/' + defaultFilter + '&EndUserId=' + invalidEndUserId + '&ServiceResource=' + auxResource); expectStatusFor(r).to.equal(200); expect(r, 'response').to.have.validJsonBody(); - expect(r.json(), 'response json').not.to.have.property("items"); + let response = r.json(); + expect(response, 'response json').to.have.property("items"); + expect(response.items, 'items').to.have.lengthOf(0); }) describe("Cleanup", () => { From 08f5c5018cf33cb5a5cdf40738a3e1d345ead09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Fri, 1 Nov 2024 13:41:57 +0100 Subject: [PATCH 3/8] chngs --- .../Program.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs index 26a40e2b3..652a97668 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs @@ -167,11 +167,6 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura TypeNameConverter.ToShortName(endpointDefinition.EndpointType))))); }; x.Serializer.Options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; - // Do not serialize empty collections - x.Serializer.Options.TypeInfoResolver = new DefaultJsonTypeInfoResolver - { - Modifiers = { IgnoreEmptyCollections } - }; x.Serializer.Options.Converters.Add(new JsonStringEnumConverter()); x.Serializer.Options.Converters.Add(new UtcDateTimeOffsetConverter()); x.Serializer.Options.Converters.Add(new DateTimeNotSupportedConverter()); @@ -207,18 +202,5 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura app.Run(); } -static void IgnoreEmptyCollections(JsonTypeInfo typeInfo) -{ - foreach (var property in typeInfo.Properties) - { - if (property.PropertyType.IsGenericType && - property.PropertyType.IsAssignableTo(typeof(ICollection)) && - property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - property.ShouldSerialize = (_, val) => val is ICollection collection && collection.Count > 0; - } - } -} - // ReSharper disable once ClassNeverInstantiated.Global public sealed partial class Program; From a2b167585fd2ef9c9cffd15cffef0f1125ee7537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Fri, 1 Nov 2024 14:26:52 +0100 Subject: [PATCH 4/8] cln --- src/Digdir.Domain.Dialogporten.WebApi/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs index 652a97668..a3b68423a 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs @@ -1,8 +1,6 @@ -using System.Collections; using System.Globalization; using System.Reflection; using System.Text.Json.Serialization; -using System.Text.Json.Serialization.Metadata; using Digdir.Domain.Dialogporten.Application; using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.Extensions.OptionExtensions; From ee0580dff66477956c0f5591a238b0715b5bdc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Mon, 4 Nov 2024 16:43:08 +0100 Subject: [PATCH 5/8] Revert "chngs" This reverts commit 08f5c5018cf33cb5a5cdf40738a3e1d345ead09d. --- .../Program.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs index a3b68423a..a7aaa8c1d 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs @@ -165,6 +165,11 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura TypeNameConverter.ToShortName(endpointDefinition.EndpointType))))); }; x.Serializer.Options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + // Do not serialize empty collections + x.Serializer.Options.TypeInfoResolver = new DefaultJsonTypeInfoResolver + { + Modifiers = { IgnoreEmptyCollections } + }; x.Serializer.Options.Converters.Add(new JsonStringEnumConverter()); x.Serializer.Options.Converters.Add(new UtcDateTimeOffsetConverter()); x.Serializer.Options.Converters.Add(new DateTimeNotSupportedConverter()); @@ -200,5 +205,18 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura app.Run(); } +static void IgnoreEmptyCollections(JsonTypeInfo typeInfo) +{ + foreach (var property in typeInfo.Properties) + { + if (property.PropertyType.IsGenericType && + property.PropertyType.IsAssignableTo(typeof(ICollection)) && + property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + property.ShouldSerialize = (_, val) => val is ICollection collection && collection.Count > 0; + } + } +} + // ReSharper disable once ClassNeverInstantiated.Global public sealed partial class Program; From ac07fd39b302df01c8ec4b2dceefa5322522f9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Mon, 4 Nov 2024 21:31:31 +0100 Subject: [PATCH 6/8] wip --- .../OpenApiDocumentExtensions.cs | 44 +++++++++++++++++++ .../Program.cs | 7 +-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs b/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs index 785dc3bb2..0a113478d 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs @@ -80,4 +80,48 @@ public static void ReplaceProblemDetailsDescriptions(this OpenApiDocument openAp } } } + + public static void MakeCollectionsNullable(this OpenApiDocument openApiDocument) + { + foreach (var schema in openApiDocument.Components.Schemas.Values) + { + MakeCollectionsNullable(schema); + } + } + + private static void MakeCollectionsNullable(JsonSchema schema) + { + List typesToIgnore = ["ProblemDetails", "ProblemDetails_Error", "V1CommonLocalizations_Localization"]; + + if (schema.Properties == null) + { + return; + } + + foreach (var property in schema.Properties.Values) + { + var id = property.Item?.Reference?.Id; + Console.WriteLine(id); + var title = property.Item?.Title; + var refTitle = property.Item?.Reference?.Title; + var reference = property.Item?.Reference?.ToString(); + + if (title is not null || refTitle is not null || (reference is not null && reference != "NJsonSchema.JsonSchema")) + { + Console.WriteLine(title); + Console.WriteLine(refTitle); + Console.WriteLine(reference); + } + + if (property.Item?.Reference?.Id != null && typesToIgnore.Contains(property.Item.Reference.Id)) + { + continue; + } + + if (property.Type.HasFlag(JsonObjectType.Array)) + { + property.IsNullableRaw = true; + } + } + } } diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs index a7aaa8c1d..77ea56e3a 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Program.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Program.cs @@ -1,6 +1,8 @@ +using System.Collections; using System.Globalization; using System.Reflection; using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Digdir.Domain.Dialogporten.Application; using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.Extensions.OptionExtensions; @@ -192,6 +194,7 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura document.Generator = null; document.ReplaceProblemDetailsDescriptions(); document.ReplaceRequestExampleBodies(); + document.MakeCollectionsNullable(); }; }, uiConfig => { @@ -209,9 +212,7 @@ static void IgnoreEmptyCollections(JsonTypeInfo typeInfo) { foreach (var property in typeInfo.Properties) { - if (property.PropertyType.IsGenericType && - property.PropertyType.IsAssignableTo(typeof(ICollection)) && - property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) + if (property.PropertyType.IsAssignableTo(typeof(ICollection))) { property.ShouldSerialize = (_, val) => val is ICollection collection && collection.Count > 0; } From c42a9fdcff62d21c5fbe40ed46e281f948974c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Wed, 6 Nov 2024 11:45:29 +0100 Subject: [PATCH 7/8] updt --- docs/schema/V1/swagger.verified.json | 84 ++++++++++++++++++- .../OpenApiDocumentExtensions.cs | 20 ----- 2 files changed, 83 insertions(+), 21 deletions(-) diff --git a/docs/schema/V1/swagger.verified.json b/docs/schema/V1/swagger.verified.json index a27f1abdf..f21ef98b5 100644 --- a/docs/schema/V1/swagger.verified.json +++ b/docs/schema/V1/swagger.verified.json @@ -211,6 +211,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesSearch_Dialog" }, + "nullable": true, "type": "array" }, "orderBy": { @@ -239,6 +240,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesSearch_Dialog" }, + "nullable": true, "type": "array" }, "orderBy": { @@ -260,6 +262,7 @@ "items": { "$ref": "#/components/schemas/ProblemDetails_Error" }, + "nullable": true, "type": "array" }, "instance": { @@ -320,6 +323,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" } }, @@ -352,6 +356,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -604,6 +609,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogActivity" }, + "nullable": true, "type": "array" }, "apiActions": { @@ -611,6 +617,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogApiAction" }, + "nullable": true, "type": "array" }, "attachments": { @@ -618,6 +625,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogAttachment" }, + "nullable": true, "type": "array" }, "content": { @@ -668,6 +676,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogGuiAction" }, + "nullable": true, "type": "array" }, "id": { @@ -713,6 +722,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogSeenLog" }, + "nullable": true, "type": "array" }, "serviceResource": { @@ -745,6 +755,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogTransmission" }, + "nullable": true, "type": "array" }, "updatedAt": { @@ -770,6 +781,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -851,6 +863,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogApiActionEndpoint" }, + "nullable": true, "type": "array" }, "id": { @@ -931,6 +944,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -943,6 +957,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogAttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -1034,6 +1049,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "url": { @@ -1101,6 +1117,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogTransmissionAttachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -1170,6 +1187,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -1182,6 +1200,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesGet_DialogTransmissionAttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -1394,6 +1413,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogsQueriesSearch_DialogSeenLog" }, + "nullable": true, "type": "array" }, "serviceResource": { @@ -1444,6 +1464,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -1576,6 +1597,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -1588,6 +1610,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogTransmissionsQueriesGet_AttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -1690,6 +1713,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogTransmissionsQueriesGet_Attachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -1764,6 +1788,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -1776,6 +1801,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogTransmissionsQueriesSearch_AttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -1878,6 +1904,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserDialogTransmissionsQueriesSearch_Attachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -1991,6 +2018,7 @@ "items": { "$ref": "#/components/schemas/V1EndUserPartiesQueriesGet_AuthorizedParty" }, + "nullable": true, "type": "array" } }, @@ -2010,6 +2038,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -2067,6 +2096,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -2180,6 +2210,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -2265,6 +2296,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_ApiActionEndpoint" }, + "nullable": true, "type": "array" } }, @@ -2330,6 +2362,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "urls": { @@ -2337,6 +2370,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_AttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -2433,6 +2467,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_Activity" }, + "nullable": true, "type": "array" }, "apiActions": { @@ -2440,6 +2475,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_ApiAction" }, + "nullable": true, "type": "array" }, "attachments": { @@ -2447,6 +2483,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_Attachment" }, + "nullable": true, "type": "array" }, "content": { @@ -2492,6 +2529,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_GuiAction" }, + "nullable": true, "type": "array" }, "id": { @@ -2527,6 +2565,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_SearchTag" }, + "nullable": true, "type": "array" }, "serviceResource": { @@ -2556,6 +2595,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_Transmission" }, + "nullable": true, "type": "array" }, "updatedAt": { @@ -2621,6 +2661,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "url": { @@ -2650,6 +2691,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_TransmissionAttachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -2717,6 +2759,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -2731,6 +2774,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_TransmissionAttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -2832,6 +2876,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -2917,6 +2962,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_ApiActionEndpoint" }, + "nullable": true, "type": "array" }, "id": { @@ -2996,6 +3042,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -3010,6 +3057,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_AttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -3113,6 +3161,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_Activity" }, + "nullable": true, "type": "array" }, "apiActions": { @@ -3120,6 +3169,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_ApiAction" }, + "nullable": true, "type": "array" }, "attachments": { @@ -3127,6 +3177,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_Attachment" }, + "nullable": true, "type": "array" }, "content": { @@ -3166,6 +3217,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_GuiAction" }, + "nullable": true, "type": "array" }, "progress": { @@ -3179,6 +3231,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_SearchTag" }, + "nullable": true, "type": "array" }, "status": { @@ -3194,6 +3247,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_Transmission" }, + "nullable": true, "type": "array" }, "visibleFrom": { @@ -3260,6 +3314,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "url": { @@ -3289,6 +3344,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_TransmissionAttachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -3356,6 +3412,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -3370,6 +3427,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_TransmissionAttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -3597,6 +3655,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogActivity" }, + "nullable": true, "type": "array" }, "apiActions": { @@ -3604,6 +3663,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogApiAction" }, + "nullable": true, "type": "array" }, "attachments": { @@ -3611,6 +3671,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogAttachment" }, + "nullable": true, "type": "array" }, "content": { @@ -3662,6 +3723,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogGuiAction" }, + "nullable": true, "type": "array" }, "id": { @@ -3715,6 +3777,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogSeenLog" }, + "nullable": true, "type": "array" }, "serviceResource": { @@ -3747,6 +3810,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogTransmission" }, + "nullable": true, "type": "array" }, "updatedAt": { @@ -3779,6 +3843,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -3860,6 +3925,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogApiActionEndpoint" }, + "nullable": true, "type": "array" }, "id": { @@ -3940,6 +4006,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -3952,6 +4019,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogAttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -4044,6 +4112,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "url": { @@ -4110,6 +4179,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogTransmissionAttachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -4180,6 +4250,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -4192,6 +4263,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesGet_DialogTransmissionAttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -4420,6 +4492,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsQueriesSearch_DialogSeenLog" }, + "nullable": true, "type": "array" }, "serviceResource": { @@ -4476,6 +4549,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "extendedType": { @@ -4603,6 +4677,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_TransmissionAttachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -4670,6 +4745,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -4682,6 +4758,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogTransmissionsQueriesGet_AttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -4784,6 +4861,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogTransmissionsQueriesGet_Attachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -4854,6 +4932,7 @@ "items": { "$ref": "#/components/schemas/V1CommonLocalizations_Localization" }, + "nullable": true, "type": "array" }, "id": { @@ -4866,6 +4945,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogTransmissionsQueriesSearch_AttachmentUrl" }, + "nullable": true, "type": "array" } }, @@ -4968,6 +5048,7 @@ "items": { "$ref": "#/components/schemas/V1ServiceOwnerDialogTransmissionsQueriesSearch_Attachment" }, + "nullable": true, "type": "array" }, "authorizationAttribute": { @@ -5037,6 +5118,7 @@ "items": { "$ref": "#/components/schemas/V1WellKnownJwksQueriesGet_Jwk" }, + "nullable": true, "type": "array" } }, @@ -7455,4 +7537,4 @@ "url": "https://altinn-dev-api.azure-api.net/dialogporten" } ] -} +} \ No newline at end of file diff --git a/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs b/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs index 0a113478d..81765706d 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs @@ -91,8 +91,6 @@ public static void MakeCollectionsNullable(this OpenApiDocument openApiDocument) private static void MakeCollectionsNullable(JsonSchema schema) { - List typesToIgnore = ["ProblemDetails", "ProblemDetails_Error", "V1CommonLocalizations_Localization"]; - if (schema.Properties == null) { return; @@ -100,24 +98,6 @@ private static void MakeCollectionsNullable(JsonSchema schema) foreach (var property in schema.Properties.Values) { - var id = property.Item?.Reference?.Id; - Console.WriteLine(id); - var title = property.Item?.Title; - var refTitle = property.Item?.Reference?.Title; - var reference = property.Item?.Reference?.ToString(); - - if (title is not null || refTitle is not null || (reference is not null && reference != "NJsonSchema.JsonSchema")) - { - Console.WriteLine(title); - Console.WriteLine(refTitle); - Console.WriteLine(reference); - } - - if (property.Item?.Reference?.Id != null && typesToIgnore.Contains(property.Item.Reference.Id)) - { - continue; - } - if (property.Type.HasFlag(JsonObjectType.Array)) { property.IsNullableRaw = true; From c4874a8b3bf2713770ef68f03e2d91c562bc13e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Wed, 6 Nov 2024 11:46:25 +0100 Subject: [PATCH 8/8] e2e --- tests/k6/tests/serviceowner/dialogSearch.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/k6/tests/serviceowner/dialogSearch.js b/tests/k6/tests/serviceowner/dialogSearch.js index eb98fbfe1..ef6e949ec 100644 --- a/tests/k6/tests/serviceowner/dialogSearch.js +++ b/tests/k6/tests/serviceowner/dialogSearch.js @@ -207,9 +207,7 @@ export default function () { let r = getSO('dialogs/' + defaultFilter + '&EndUserId=' + invalidEndUserId + '&ServiceResource=' + auxResource); expectStatusFor(r).to.equal(200); expect(r, 'response').to.have.validJsonBody(); - let response = r.json(); - expect(response, 'response json').to.have.property("items"); - expect(response.items, 'items').to.have.lengthOf(0); + expect(r.json(), 'response json').not.to.have.property("items"); }) describe("Cleanup", () => {