Skip to content
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

AttributeRouteStrategy ignores ODataRoutePrefix when generating the path template #71

Closed
jalstrup opened this issue Feb 24, 2016 · 5 comments
Labels

Comments

@jalstrup
Copy link

We are running into an issue with the path templates not being generated correctly when using an ODataRoutePrefix. Our OData endpoint is set up in the following way.

Config

config.MapODataServiceRoute("AdminOData", "api/v1/admin", ODataEdmModelProvider.GetEdmModel());

Controller

    [ODataRoutePrefix("products")]
    public class ProductsController : ODataController
    {
        [EnableQuery]
        [ODataRoute("({key})/attributevalues({attributevalueKey})")]
        public IHttpActionResult GetAttributeValue(Guid key, Guid attributevalueKey)
        {
            return this.Ok();
        }
    }

It looks like the ODataActionDescriptor is created by the AttributeRouteStrategy. To generate the path template it looks like it is using the ODataRoute prefix (in this scenario "api/v1/admin") and ODataRouteAttribute.PathTemplate (in this scenario "({key})/attributevalues({attributevalueKey})") to generate the path template. The resulting path template ends up looking like the following.

api/v1/admin/({key})/attributevalues({attributevalueKey})

I would expect it to be

api/v1/admin/products({key})/attributevalues({attributevalueKey})

I think the same logic that is being used by AttributeRoutingConvention.GetODataPathTemplate would be needed to generate the correct path.

@ghost ghost added the bug label Feb 25, 2016
@rbeauchamp
Copy link
Owner

Hey @jalstrup, thanks for posting this issue. I'll look into it.

@mjolka
Copy link
Contributor

mjolka commented Mar 24, 2016

@rbeauchamp I've created a branch that hopefully fixes this problem. Please let me know if you have any feedback, or would be willing to merge.

@rbeauchamp
Copy link
Owner

@mjolka Thank you! Please submit a pull request and I'll check it out.

@ghost
Copy link

ghost commented Mar 29, 2016

Fixed by #84.

@ghost ghost closed this as completed Mar 29, 2016
@ghost
Copy link

ghost commented Mar 29, 2016

Fix is available in v2.18.0

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

No branches or pull requests

3 participants