@@ -44,8 +44,10 @@ internal class NavigationPropertyPathItemHandler : PathItemHandler
44
44
/// </summary>
45
45
protected bool LastSegmentIsRefSegment { get ; private set ; }
46
46
47
- /// <inheritdoc/>
48
- protected override void SetOperations ( OpenApiPathItem item )
47
+ private IEdmEntityType _entityType ;
48
+
49
+ /// <inheritdoc/>
50
+ protected override void SetOperations ( OpenApiPathItem item )
49
51
{
50
52
IEdmEntitySet entitySet = NavigationSource as IEdmEntitySet ;
51
53
IEdmVocabularyAnnotatable target = entitySet ;
@@ -78,12 +80,16 @@ protected override void SetOperations(OpenApiPathItem item)
78
80
{
79
81
if ( LastSegmentIsKeySegment )
80
82
{
81
- AddUpdateOperation ( item , restriction ) ;
83
+ UpdateRestrictionsType updateEntity = Context . Model . GetRecord < UpdateRestrictionsType > ( _entityType ) ;
84
+ if ( updateEntity ? . IsUpdatable ?? true )
85
+ {
86
+ AddUpdateOperation ( item , restriction ) ;
87
+ }
82
88
}
83
89
else
84
90
{
85
91
InsertRestrictionsType insert = restriction ? . InsertRestrictions ;
86
- if ( insert == null || insert . IsInsertable )
92
+ if ( insert ? . IsInsertable ?? true )
87
93
{
88
94
AddOperation ( item , OperationType . Post ) ;
89
95
}
@@ -121,7 +127,8 @@ private void AddGetOperation(OpenApiPathItem item, NavigationPropertyRestriction
121
127
}
122
128
else
123
129
{
124
- if ( read . IsReadable )
130
+ ReadRestrictionsType readEntity = Context . Model . GetRecord < ReadRestrictionsType > ( _entityType ) ;
131
+ if ( readEntity ? . IsReadable ?? true )
125
132
{
126
133
AddOperation ( item , OperationType . Get ) ;
127
134
}
@@ -155,13 +162,17 @@ private void AddDeleteOperation(OpenApiPathItem item, NavigationPropertyRestrict
155
162
}
156
163
157
164
DeleteRestrictionsType delete = restriction ? . DeleteRestrictions ;
158
- if ( delete == null || delete . IsDeletable )
165
+ DeleteRestrictionsType deleteEntity = Context . Model . GetRecord < DeleteRestrictionsType > ( _entityType ) ;
166
+ bool isDeletableDefault = delete == null && deleteEntity == null ;
167
+
168
+ if ( isDeletableDefault ||
169
+ ( delete ? . IsDeletable ?? false ) ||
170
+ ( deleteEntity ? . IsDeletable ?? false ) )
159
171
{
160
172
if ( NavigationProperty . TargetMultiplicity ( ) != EdmMultiplicity . Many || LastSegmentIsKeySegment )
161
173
{
162
174
AddOperation ( item , OperationType . Delete ) ;
163
175
}
164
-
165
176
return ;
166
177
}
167
178
}
@@ -193,6 +204,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
193
204
LastSegmentIsKeySegment = path . LastSegment . Kind == ODataSegmentKind . Key ;
194
205
LastSegmentIsRefSegment = path . LastSegment . Kind == ODataSegmentKind . Ref ;
195
206
NavigationProperty = path . OfType < ODataNavigationPropertySegment > ( ) . Last ( ) . NavigationProperty ;
207
+ _entityType = NavigationProperty . ToEntityType ( ) ;
196
208
}
197
209
198
210
/// <inheritdoc/>
0 commit comments