WebApi icon indicating copy to clipboard operation
WebApi copied to clipboard

ODataPathSegmentHandler is not aware of key-as-segment

Open maximpashuk opened this issue 6 years ago • 2 comments

Hi I am using Microsoft.AspNetCore.OData 7.0.1

I am trying to use key-as-segment (users/1 instead of users(1))

I set SetUrlKeyDelimiter(ODataUrlKeyDelimiter.Slash), also set up ODataSimplifiedOptions and enable EnableReadingKeyAsSegment and EnableWritingKeyAsSegment.

Most of the thing works fine (parsing, simplified namespaces), except one thing.

EditLink generated in mixed-style, both parentheses-style and key-as-segment in one url

"@editLink": "users(30)/profiles/test"

Without key-as-segment and namespace simplifications response is

"@odata.editLink": "users(30)/profiles('test')"

I made some research and found, that problem in ODataPathSegmentHandler.Handle(KeySegment)

It unconditionally uses parentheses-style for handling KeySegment.

I think ODataPathSegmentHandler shoul be refactored to support key-as-segment.

maximpashuk avatar Aug 30 '18 23:08 maximpashuk

Hi again, recently I updated my project to Microsoft.AspNetCore.OData, Version 8.0.8, and this bug is still present in 2022.

maximpashuk avatar Mar 09 '22 07:03 maximpashuk

i have created a sample project in OData v8 and facing the same issue

bug: https://github.com/OData/AspNetCoreOData/issues/606

Repository: https://github.com/padhumailin/ODataRouteComponent

image

padhumailin avatar May 30 '22 11:05 padhumailin