Skip to content

Commit 90e7ddc

Browse files
authored
Adds support for alternate keys to collection navigation properties (#454)
* Append alternate keys to collection navigation properties * Update tests * Updates release notes
1 parent f97b4e3 commit 90e7ddc

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ private void RetrieveNavigationPropertyPaths(
597597
// append a navigation property key.
598598
if (targetsMany)
599599
{
600+
CreateAlternateKeyPath(currentPath, navEntityType);
601+
600602
currentPath.Push(new ODataKeySegment(navEntityType));
601603
AppendPath(currentPath.Clone());
602604

src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<TargetFrameworks>netstandard2.0</TargetFrameworks>
1616
<PackageId>Microsoft.OpenApi.OData</PackageId>
1717
<SignAssembly>true</SignAssembly>
18-
<Version>1.5.0-preview10</Version>
18+
<Version>1.5.0-preview11</Version>
1919
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
2020
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
2121
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
@@ -31,6 +31,7 @@
3131
- Retrieves complex properties of derived types #437
3232
- Updates operationIds of navigation property paths with OData type cast segments #442
3333
- Generate navigation property paths defined in nested complex properties #446
34+
- Adds support for alternate keys to collection navigation properties #410
3435
</PackageReleaseNotes>
3536
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
3637
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>

test/Microsoft.OpenAPI.OData.Reader.Tests/Edm/ODataPathProviderTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void GetPathsForGraphBetaModelReturnsAllPaths()
5252

5353
// Assert
5454
Assert.NotNull(paths);
55-
Assert.Equal(16967, paths.Count());
55+
Assert.Equal(16976, paths.Count());
5656
AssertGraphBetaModelPaths(paths);
5757
}
5858

@@ -93,6 +93,10 @@ private void AssertGraphBetaModelPaths(IEnumerable<ODataPath> paths)
9393
// Test that navigation properties within nested complex properties are appended
9494
Assert.NotNull(paths.FirstOrDefault(p => p.GetPathItemName().Equals(
9595
"/identity/authenticationEventsFlows({id})/conditions/applications/includeApplications")));
96+
97+
// Test that alternate keys are appended for collection navigation properties
98+
Assert.NotNull(paths.FirstOrDefault(p => p.GetPathItemName().Equals(
99+
"/employeeExperience/learningProviders({id})/learningContents(externalId='{externalId}')")));
96100
}
97101

98102
[Fact]
@@ -113,7 +117,7 @@ public void GetPathsForGraphBetaModelWithDerivedTypesConstraintReturnsAllPaths()
113117

114118
// Assert
115119
Assert.NotNull(paths);
116-
Assert.Equal(17618, paths.Count());
120+
Assert.Equal(17627, paths.Count());
117121
}
118122

119123
[Theory]

0 commit comments

Comments
 (0)