Skip to content

Multiple versions of Orders Controller and routes not found #825

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
rgtek opened this issue Apr 26, 2022 · 5 comments
Closed

Multiple versions of Orders Controller and routes not found #825

rgtek opened this issue Apr 26, 2022 · 5 comments

Comments

@rgtek
Copy link

rgtek commented Apr 26, 2022

On the project ODataOpenApiExample, it appears that the OrdersController V3 is not working correctly. For example, both the Patch request and the Get request return a 404. See screenshots below. May be I am missing something?

Orders Get

Orders Patch

@commonsensesoftware
Copy link
Collaborator

Strange, but not impossible. I'll investigate. Thanks for reporting it.

@rgtek
Copy link
Author

rgtek commented Apr 27, 2022

Yeah... I thought so. The only way I was able to get V3 to work was just by changing the OrderModelConfiguration as below even though it seems to follow the same pattern as the PersonModelConfiguration which does not appear to be affected.

`public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
{
if ( apiVersion < ApiVersions.V3 )
{
return;
}

    var order = builder.EntitySet<Order>( "Orders" ).EntityType.HasKey( o => o.Id );
    var lineItem = builder.EntityType<LineItem>().HasKey( li => li.Number );

    //if ( apiVersion < ApiVersions.V2 )
    //{
    //    order.Ignore( o => o.EffectiveDate );
    //    lineItem.Ignore( li => li.Fulfilled );
    //}

    //if ( apiVersion < ApiVersions.V3 )
    //{
    //    order.Ignore( o => o.Description );
    //}

    //if ( apiVersion == ApiVersions.V1 )
    //{
    //    order.Function( "MostExpensive" ).ReturnsFromEntitySet<Order>( "Orders" );
    //}

    //if ( apiVersion >= ApiVersions.V1 )
    //{
    //    order.Collection.Function( "MostExpensive" ).ReturnsFromEntitySet<Order>( "Orders" );
    //}

    //if ( apiVersion >= ApiVersions.V2 )
    //{
    //    order.Action( "Rate" ).Parameter<int>( "rating" );
    //}

}`

@commonsensesoftware
Copy link
Collaborator

Similar issue as #821

@commonsensesoftware
Copy link
Collaborator

Long story short, this was a bug. If you're interested in the details, see #821.

Preview 3 is now available and contains the fix for this issue. I've also gone through all of the OData OpenAPI examples to verify that they should all work. 😉 Let me know if this resolves your issue.

@rgtek
Copy link
Author

rgtek commented May 10, 2022

Thank you. It is now working correctly for me. Good job.

@rgtek rgtek closed this as completed May 10, 2022
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