Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for alternate keys to collection navigation properties #454

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ private void RetrieveNavigationPropertyPaths(
// append a navigation property key.
if (targetsMany)
{
CreateAlternateKeyPath(currentPath, navEntityType);

currentPath.Push(new ODataKeySegment(navEntityType));
AppendPath(currentPath.Clone());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageId>Microsoft.OpenApi.OData</PackageId>
<SignAssembly>true</SignAssembly>
<Version>1.5.0-preview10</Version>
<Version>1.5.0-preview11</Version>
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
Expand All @@ -31,6 +31,7 @@
- Retrieves complex properties of derived types #437
- Updates operationIds of navigation property paths with OData type cast segments #442
- Generate navigation property paths defined in nested complex properties #446
- Adds support for alternate keys to collection navigation properties #410
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void GetPathsForGraphBetaModelReturnsAllPaths()

// Assert
Assert.NotNull(paths);
Assert.Equal(16967, paths.Count());
Assert.Equal(16976, paths.Count());
AssertGraphBetaModelPaths(paths);
}

Expand Down Expand Up @@ -93,6 +93,10 @@ private void AssertGraphBetaModelPaths(IEnumerable<ODataPath> paths)
// Test that navigation properties within nested complex properties are appended
Assert.NotNull(paths.FirstOrDefault(p => p.GetPathItemName().Equals(
"/identity/authenticationEventsFlows({id})/conditions/applications/includeApplications")));

// Test that alternate keys are appended for collection navigation properties
Assert.NotNull(paths.FirstOrDefault(p => p.GetPathItemName().Equals(
"/employeeExperience/learningProviders({id})/learningContents(externalId='{externalId}')")));
}

[Fact]
Expand All @@ -113,7 +117,7 @@ public void GetPathsForGraphBetaModelWithDerivedTypesConstraintReturnsAllPaths()

// Assert
Assert.NotNull(paths);
Assert.Equal(17618, paths.Count());
Assert.Equal(17627, paths.Count());
}

[Theory]
Expand Down
Loading