Skip to content

Commit 2f6459e

Browse files
authored
Merge pull request #677 from microsoft/fix/null-alternate-key
fix: filter out not found alternate keys properties
2 parents d2a56d9 + 6672d76 commit 2f6459e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,9 @@ private void CreateAlternateKeyPath(ODataPath currentPath, IEdmEntityType entity
705705
IEnumerable<IDictionary<string, IEdmProperty>> alternateKeys = _model.GetAlternateKeysAnnotation(entityType);
706706
foreach (var keyDict in alternateKeys)
707707
{
708+
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)
709+
continue;
708710
ODataPath keyPath = currentPath.Clone();
709-
IDictionary<string, string> keyMappings = keyDict.ToDictionary(static k => k.Key, static v => v.Value.Name);
710711
ODataKeySegment keySegment = new(entityType, keyMappings)
711712
{
712713
IsAlternateKey = true

0 commit comments

Comments
 (0)