diff --git a/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs b/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs
index 84955dfc..45e22c69 100644
--- a/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs
+++ b/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs
@@ -393,25 +393,26 @@ internal static string StripOrAliasNamespacePrefix(IEdmSchemaElement element, Op
return segmentName;
}
-
+
///
/// Checks whether an operation is allowed on a model element.
///
/// The Edm model.
/// The target operation.
/// The model element.
+ /// Optional: Default is true.
+ /// The operation will be allowed by default if the annotation Org.OData.Core.V1.RequiresExplicitBinding is undefined for the given operation.
/// true if the operation is allowed, otherwise false.
- internal static bool IsOperationAllowed(IEdmModel model, IEdmOperation edmOperation, IEdmVocabularyAnnotatable annotatable)
+ internal static bool IsOperationAllowed(IEdmModel model, IEdmOperation edmOperation, IEdmVocabularyAnnotatable annotatable, bool operationAllowed = true)
{
Utils.CheckArgumentNull(model, nameof(model));
Utils.CheckArgumentNull(edmOperation, nameof(edmOperation));
Utils.CheckArgumentNull(annotatable, nameof(annotatable));
var requiresExplicitBinding = model.FindVocabularyAnnotations(edmOperation).FirstOrDefault(x => x.Term.Name == CapabilitiesConstants.RequiresExplicitBindingName);
-
if (requiresExplicitBinding == null)
{
- return true;
+ return operationAllowed;
}
var boundOperations = model.GetCollection(annotatable, CapabilitiesConstants.ExplicitOperationBindings)?.ToList();
diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs
index c516f055..8c81f4b3 100644
--- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs
+++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs
@@ -802,7 +802,7 @@ secondLastPathSegment is not ODataKeySegment &&
if (annotatable != null && !EdmModelHelper.IsOperationAllowed(_model, edmOperation, annotatable))
{
continue;
- }
+ }
}
ODataPath newPath = subPath.Clone();
@@ -824,13 +824,8 @@ private void AppendBoundOperationOnNavigationPropertyPath(IEdmOperation edmOpera
foreach (var path in value.Where(x => !_pathKindToSkipForNavigationProperties.Contains(x.Kind)))
{
ODataNavigationPropertySegment npSegment = path.Segments.Last(s => s is ODataNavigationPropertySegment) as ODataNavigationPropertySegment;
-
- if (!npSegment.NavigationProperty.ContainsTarget)
- {
- continue;
- }
- if (!EdmModelHelper.IsOperationAllowed(_model, edmOperation, npSegment.NavigationProperty))
+ if (!EdmModelHelper.IsOperationAllowed(_model, edmOperation, npSegment.NavigationProperty, npSegment.NavigationProperty.ContainsTarget))
{
continue;
}
@@ -954,12 +949,7 @@ private void AppendBoundOperationOnDerivedNavigationPropertyPath(
continue;
}
- if (!npSegment.NavigationProperty.ContainsTarget)
- {
- continue;
- }
-
- if (!EdmModelHelper.IsOperationAllowed(_model, edmOperation, npSegment.NavigationProperty))
+ if (!EdmModelHelper.IsOperationAllowed(_model, edmOperation, npSegment.NavigationProperty, npSegment.NavigationProperty.ContainsTarget))
{
continue;
}
diff --git a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj
index 036ea5a6..4c537ad9 100644
--- a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj
+++ b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj
@@ -15,7 +15,7 @@
netstandard2.0
Microsoft.OpenApi.OData
true
- 1.5.0-preview4
+ 1.5.0-preview5
This package contains the codes you need to convert OData CSDL to Open API Document of Model.
© Microsoft Corporation. All rights reserved.
Microsoft OpenApi OData EDM
@@ -25,6 +25,7 @@
- Updates README #13, #253, #40
- Fixes casing in default propertyName for `innerError` in the `ErrorMainSchema`
- Adds support for `x-ms-enum-flags` extension for flagged enums
+- Use containment together with RequiresExplicitBinding annotation to check whether to append bound operations to navigation properties #430
Microsoft.OpenApi.OData.Reader
..\..\tool\Microsoft.OpenApi.OData.snk