Skip to content

Commit 888feef

Browse files
The OData specification should internally match entire controllers or a subset of their actions. Fixes #1118
1 parent bd469de commit 888feef

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/AspNetCore/OData/src/Asp.Versioning.OData/ApplicationModels/ODataControllerSpecification.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Asp.Versioning.ApplicationModels;
44

55
using Microsoft.AspNetCore.Mvc.ApplicationModels;
6+
using Microsoft.AspNetCore.OData.Edm;
67
using Microsoft.AspNetCore.OData.Routing.Attributes;
78

89
/// <summary>
@@ -16,7 +17,7 @@ public bool IsSatisfiedBy( ControllerModel controller )
1617
{
1718
ArgumentNullException.ThrowIfNull( controller );
1819

19-
if ( ODataControllerSpecification.IsSatisfiedBy( controller ) )
20+
if ( Matches( controller ) )
2021
{
2122
return true;
2223
}
@@ -25,7 +26,7 @@ public bool IsSatisfiedBy( ControllerModel controller )
2526

2627
for ( var i = 0; i < actions.Count; i++ )
2728
{
28-
if ( IsSatisfiedBy( actions[i] ) )
29+
if ( Matches( actions[i] ) )
2930
{
3031
return true;
3132
}
@@ -34,7 +35,7 @@ public bool IsSatisfiedBy( ControllerModel controller )
3435
return false;
3536
}
3637

37-
internal static bool IsSatisfiedBy( ICommonModel model )
38+
internal static bool Matches( ICommonModel model )
3839
{
3940
var attributes = model.Attributes;
4041

src/AspNetCore/OData/src/Asp.Versioning.OData/OData/ODataApplicationModelProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ private static
7979
CollateApiVersions( ApplicationModel application )
8080
{
8181
var controllers = application.Controllers;
82+
var specification = new ODataControllerSpecification();
8283
var metadataControllers = default( List<ControllerModel> );
8384
var supported = default( SortedSet<ApiVersion> );
8485
var deprecated = default( SortedSet<ApiVersion> );
@@ -93,7 +94,7 @@ private static
9394
metadataControllers.Add( controller );
9495
continue;
9596
}
96-
else if ( !ODataControllerSpecification.IsSatisfiedBy( controller ) )
97+
else if ( !specification.IsSatisfiedBy( controller ) )
9798
{
9899
continue;
99100
}

src/AspNetCore/OData/src/Asp.Versioning.OData/Routing/VersionedAttributeRoutingConvention.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ public override bool AppliesToAction( ODataControllerActionContext context )
9595

9696
private static bool IsODataController( ODataControllerActionContext context )
9797
{
98-
if ( ODataControllerSpecification.IsSatisfiedBy( context.Controller ) )
98+
if ( ODataControllerSpecification.Matches( context.Controller ) )
9999
{
100100
return true;
101101
}
102102

103-
return ODataControllerSpecification.IsSatisfiedBy( context.Action );
103+
return ODataControllerSpecification.Matches( context.Action );
104104
}
105105

106106
private static IEdmModel? FindModel( ODataControllerActionContext context )

0 commit comments

Comments
 (0)