From 7cd11b4a59d3ca102e15f0596b39cd0934f63076 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 31 Mar 2025 14:00:19 -0400 Subject: [PATCH] fix: filter out not found alternate keys properties --- src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs index 0c5a17fb..1c12bef6 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs @@ -705,8 +705,9 @@ private void CreateAlternateKeyPath(ODataPath currentPath, IEdmEntityType entity IEnumerable> alternateKeys = _model.GetAlternateKeysAnnotation(entityType); foreach (var keyDict in alternateKeys) { + if (keyDict.Where(static x => x.Value is not null).ToDictionary(static k => k.Key, static v => v.Value.Name) is not { Count: > 0 } keyMappings) + continue; ODataPath keyPath = currentPath.Clone(); - IDictionary keyMappings = keyDict.ToDictionary(static k => k.Key, static v => v.Value.Name); ODataKeySegment keySegment = new(entityType, keyMappings) { IsAlternateKey = true