Skip to content

PostTo Issue #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
strandman opened this issue Apr 30, 2021 · 3 comments
Closed

PostTo Issue #742

strandman opened this issue Apr 30, 2021 · 3 comments
Assignees

Comments

@strandman
Copy link

strandman commented Apr 30, 2021

According to built-in-routing-conventions you should be able to Post to Navigation Collection Properties.

But it seems like #573 is hard coded to "CreateRef":
ODataRouteBuilderContext.cs

Valid Post actions on collection navigation properties is also:
PostTo{PropertyName} and PostTo{PropertyName}From{EntityName}

@commonsensesoftware
Copy link
Collaborator

Is there actually an issue or you just made an observation?

It's possible something was missed, but this particular part of route building is not attempting to build the full path. This is looking for the root part of the OData path, which can only be:

  1. An entity set (e.g. collection)
  2. A singleton
  3. An unbounded action or function

The place where this looks like it might be an issue is inside IsNavigationPropertyLink. It covers {HttpMethod}{PropertyName}, but not {HttpMethod}To{PropertyName}.

While that is worth fixing, the only scenario I see that would be an issue is that a navigation property could be misinterpreted as an action or function.

The documentation for OData conventions is useful, but I don't trust it due to painful history lessons. I reference the conventions/templates found directly in the code as the source of truth.

@strandman
Copy link
Author

Is there actually an issue or you just made an observation?
The place where this looks like it might be an issue is inside IsNavigationPropertyLink. It covers {HttpMethod}{PropertyName}, but not {HttpMethod}To{PropertyName}

Yes it is an issue because ODataActionDescriptorProvider.cs#L55 removes the ActionDescriptor and It'll not be readded because IsRouteExcluded = ActionType == ODataRouteActionType.Unknown and will never hit ODataRouteBindingInfoConvention.cs#L156. PutTo and PatchTo works simply because ODataRouteBuilderContext.cs#L127 ignores those verbs.

The documentation for OData conventions is useful, but I don't trust it due to painful history lessons. I reference the conventions/templates found directly in the code as the source of truth.

Yes I understand, the navigation template you should look at is: NavigationRoutingConvention.cs#L85

Sorry for bad grammar, I'm not an English speaking person ;)

@commonsensesoftware
Copy link
Collaborator

Thanks for the confirmation. It looks like this use case is indeed missed so I'm going to go ahead and mark it as a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants