Adding condition :min(1) to route parameter breaks OData routing
Open
@xuzhg is already working on this.
Since Nov 19, 2024.
bug
P2
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Assemblies affected
.NET 9.0
Microsoft.AspNetCore.OData 9.1.0
Microsoft.OData.Core 8.21
Describe the bug
[ApiExplorerSettings(GroupName = "OData")]
[ODataRouteComponent("global")]
[Route("/odata/global")]
public class SystemDataTypeController(GlobalDbContext _db) : ODataController
{
[EnableQuery]
[HttpGet("SystemDataType")]
public IQueryable Get()
{
return _db.SystemDataTypes.AsNoTracking();
}
[EnableQuery]
[HttpGet("SystemDataType/{id:int}")] // <--------------------------------- This works, but id:int:min(1) breaks the routing
[HttpGet("SystemDataType({id:int:min(1)})")] <--------------------------- This works, with or without condition
public SingleResult<SystemDataType> GetById([FromRoute] uint id)
{
return SingleResult.Create(_db.SystemDataTypes.Where(x => x.Id == id).AsNoTracking());
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.