AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Unable to disable default path templates

Open sindhuselvaraj opened this issue 3 years ago • 0 comments
trafficstars

Assemblies affected ASP.NET Core OData 8.x

Describe the bug I have an application that uses OData 8 with .net 7 For all the ODataControllers, the built-in routing conventions by default add additional path templates/Segment templates for Get, Put and Delete with no option to disable these. I want to be able to disable the "$count" segment, "Functions." segment and I think model being added is a cast segment.

Reproduce steps Create a ODataController with below endpoints

[HttpGet] [EnableQuery] public IActionResult GetDataSource()

[HttpGet] [EnableQuery] public async Task GetDataSource(int key)

[HttpPost] public async Task PostDataSource([FromBody] DataSource)

[HttpDelete] public async Task DeleteDataSource(int key)

ConfigureServices has below configuration

services.AddControllers() .AddOData(options => { options.RouteOptions.EnableKeyAsSegment = false; options.RouteOptions.EnableKeyInParenthesis = true; });

Expected behavior Additional path templates should not be added by default or there should be an option to disable them like below

options.RouteOptions.EnableKeyAsSegment = false; options.RouteOptions.EnableKeyInParenthesis = true;

I have tried setting bewlo, but it doesnt work options.RouteOptions.EnableQualifiedOperationCall = true; options.RouteOptions.EnableUnqualifiedOperationCall = false;

Screenshots image

image

sindhuselvaraj avatar Oct 13 '22 21:10 sindhuselvaraj