Skip to content

Commit 5b50c6c

Browse files
[Fix] Retrieves navigation properties from base types (#377)
* Get navigation properties for base types * Update unit tests * Update integration tests * Add unit test * Update release notes * Update tests --------- Co-authored-by: Millicent Achieng <[email protected]>
1 parent 4cdad1f commit 5b50c6c

File tree

7 files changed

+56167
-17675
lines changed

7 files changed

+56167
-17675
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private void RetrieveNavigationSourcePaths(IEdmNavigationSource navigationSource
274274
RetrieveComplexPropertyPaths(entityType, path, convertSettings);
275275

276276
// navigation property
277-
foreach (IEdmNavigationProperty np in entityType.DeclaredNavigationProperties())
277+
foreach (IEdmNavigationProperty np in entityType.NavigationProperties())
278278
{
279279
if (CanFilter(np))
280280
{
@@ -553,7 +553,7 @@ private void RetrieveNavigationPropertyPaths(
553553
if (shouldExpand)
554554
{
555555
// expand to sub navigation properties
556-
foreach (IEdmNavigationProperty subNavProperty in navEntityType.DeclaredNavigationProperties())
556+
foreach (IEdmNavigationProperty subNavProperty in navEntityType.NavigationProperties())
557557
{
558558
if (CanFilter(subNavProperty))
559559
{
@@ -693,7 +693,7 @@ bool filter(IEdmStructuredType x) =>
693693
continue;
694694
}
695695

696-
foreach (var declaredNavigationProperty in targetType.DeclaredNavigationProperties())
696+
foreach (var declaredNavigationProperty in targetType.NavigationProperties())
697697
{
698698
RetrieveNavigationPropertyPaths(declaredNavigationProperty, null, castPath, convertSettings);
699699
}

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

Lines changed: 3 additions & 2 deletions
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.4.0-preview5</Version>
18+
<Version>1.4.0-preview6</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>
@@ -25,7 +25,8 @@
2525
- Aliases or strips namespace prefixes from segment names when and where applicable #365
2626
- Adds support for all Org.OData.Core.V1.RevisionKind enum values #372
2727
- Use directly annotated CountRestriction annotations when creating $count segments for collection-valued navigation properties #328
28-
- Use MediaType annotation to set the content types of operations with Edm.Stream return types #342
28+
- Use MediaType annotation to set the content types of operations with Edm.Stream return types #342
29+
- Retrieves navigation properties from base types #371
2930
</PackageReleaseNotes>
3031
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
3132
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>

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

Lines changed: 5 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(18050, paths.Count());
55+
Assert.Equal(18409, paths.Count());
5656
AssertGraphBetaModelPaths(paths);
5757
}
5858

@@ -67,6 +67,9 @@ private void AssertGraphBetaModelPaths(IEnumerable<ODataPath> paths)
6767

6868
// Test that count restrictions annotations for navigation properties work
6969
Assert.Null(paths.FirstOrDefault(p => p.GetPathItemName().Equals("/me/drives/$count")));
70+
71+
// Test that navigation properties on base types are created
72+
Assert.NotNull(paths.FirstOrDefault(p => p.GetPathItemName().Equals("/print/printers({id})/jobs")));
7073
}
7174

7275
[Fact]
@@ -87,7 +90,7 @@ public void GetPathsForGraphBetaModelWithDerivedTypesConstraintReturnsAllPaths()
8790

8891
// Assert
8992
Assert.NotNull(paths);
90-
Assert.Equal(18701, paths.Count());
93+
Assert.Equal(19060, paths.Count());
9194
}
9295

9396
[Theory]

0 commit comments

Comments
 (0)