Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
In the application I'm working on there are several controllers which need OData to be enabled on specific actions only.
ASP.NET OData provides two ways of defining this:
- marking the controller type with
[ODataAttributeRouting]
(or inheriting fromODataController
) and marking methods which should be excluded from OData with[ODataIgnored]
, - marking only certain methods of the controller with
[ODataAttributeRouting]
.
Most of Asp.Versioning looks for ODataAttributeRoutingAttribute
at both controller and action level. Unfortunately, ODataApplicationModelProvider
checks the presence of this attribute at controller level only, by calling the static method ODataControllerSpecification.IsSatisfiedBy(ICommonModel model)
. This prevents method 2 above from working correctly, because the ODataApiVersionCollectionProvider.ApiVersions
collection does not get populated, ODataMultiModelApplicationModelProvider
does not get any models from VersionedODataModelBuilder
and ultimately ODataRoutingMetadata
is not set in the action endpoint metadata.
Expected Behavior
ODataApplicationModelProvider
should consider all controller actions for which either 1) the controller is decorated with [ODataAttributeRouting]
and the action is not decorated with [ODataIgnored]
, or 2) the action is decorated with [ODataAttributeRouting]
.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
.NET 8.0.11, Microsoft.AspNetCore.OData 8.2.7, Asp.Versioning 8.1.0
Anything else?
The issue is not very critical for my team, because we can mark the entire controllers with ODataAttributeRouting as a workaround. However, it was surprising, cost us some debugging time and the behavior is in conflict with the Microsoft documentation, so I wanted to leave at least a description of it here.
Thank you a lot for creating and maintaining this project!