Skip to content

ASP.NET ApiVersioning 5.1 Issues #1012

Open
@akristanto

Description

@akristanto

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After upgrading Microsoft.AspNetCore.OData.Versioning and Microsoft.AspNetCore.Mvc.Versioning from 4.1.1 to 5.1.0 and resolving the breaking changes listed here, I found that a couple APIs stopped working.

  • Some action APIs are not able to be found (404) even where some actions within the same controller were working. example:
// {ServiceName}/{EntityName}({key})/{action}
[ODataRoute("({key})/" + Constants.ActionName)]
public IActionResult Action([FromODataUri] string key, ODataActionParameters parameters)
  • Entity relation parameters tagged with [FromODataUri] are empty for both to a single entity and collection. example:
    Expected the passed in guid but found 00000000-0000-0000-0000-000000000000
// {ServiceName}/{EntityName}({key})/Entity/$ref
[HttpPut]
public IActionResult CreateRefToEntity([FromODataUri] Guid key, [FromBody]Uri link)

// {ServiceName}/{EntityName}({key})/Collection/$ref
[HttpPost]
public IActionResult CreateRefToCollection([FromODataUri] Guid key, [FromBody] Uri link)
  • There were also some other issues that were resolved by updating the ODataRoute. example:
    Adding [ODataRoute({key})] resolved null value for key
[AcceptVerbs("POST", "PUT")]
public async Task<IActionResult> Put(int key, [FromBody] Customer customer, ODataQueryOptions<Customer> options)

Are these issues expected after upgrading Microsoft.AspNetCore.OData.Versioning and Microsoft.AspNetCore.Mvc.Versioning from 4.1.1 to 5.1.0? How do we resolve these errors / debug to find the correct URI?

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.408

Anything else?

ASP.NET Core 6.0

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions