Problem
The GET, PUT, and DELETE endpoints that look up a player by squad number expose the value directly at /players/{value}, relying on ASP.NET Core's :int route constraint to disambiguate them from the /players/{id:Guid} endpoint. This leaks a framework-specific implementation detail into the URL design — a REST client has no way to know the path accepts only integers without prior knowledge of the framework.
Proposed Solution
Scope the squad number under a dedicated path segment, making the URL self-describing and decoupled from ASP.NET Core's type-constraint disambiguation mechanism:
GET /players/squadNumber/9
PUT /players/squadNumber/9
DELETE /players/squadNumber/9
Suggested Approach
Update the route templates in PlayerController.cs:
- [HttpGet("{squadNumber:int}", Name = "RetrieveBySquadNumber")]
+ [HttpGet("squadNumber/{squadNumber:int}", Name = "RetrieveBySquadNumber")]
- [HttpPut("{squadNumber:int}", Name = "Update")]
+ [HttpPut("squadNumber/{squadNumber:int}", Name = "Update")]
- [HttpDelete("{squadNumber:int}", Name = "Delete")]
+ [HttpDelete("squadNumber/{squadNumber:int}", Name = "Delete")]
Then update README.md to reflect the new paths:
- - `GET /players/{squadNumber:int}` - Get player by squad number
- - `PUT /players/{squadNumber:int}` - Update player
- - `DELETE /players/{squadNumber:int}` - Remove player
+ - `GET /players/squadNumber/{squadNumber:int}` - Get player by squad number
+ - `PUT /players/squadNumber/{squadNumber:int}` - Update player
+ - `DELETE /players/squadNumber/{squadNumber:int}` - Remove player
Acceptance Criteria
References
- REST API Design: Resource Naming
- Affects:
src/Dotnet.Samples.AspNetCore.WebApi/Controllers/PlayerController.cs (lines 127, 162, 207)
- Affects:
README.md — API Reference section
Problem
The
GET,PUT, andDELETEendpoints that look up a player by squad number expose the value directly at/players/{value}, relying on ASP.NET Core's:introute constraint to disambiguate them from the/players/{id:Guid}endpoint. This leaks a framework-specific implementation detail into the URL design — a REST client has no way to know the path accepts only integers without prior knowledge of the framework.Proposed Solution
Scope the squad number under a dedicated path segment, making the URL self-describing and decoupled from ASP.NET Core's type-constraint disambiguation mechanism:
Suggested Approach
Update the route templates in
PlayerController.cs:Then update
README.mdto reflect the new paths:Acceptance Criteria
GET /players/squadNumber/{squadNumber:int}returns the correct playerPUT /players/squadNumber/{squadNumber:int}updates the correct playerDELETE /players/squadNumber/{squadNumber:int}deletes the correct player/players/{int}) return404 Not FoundREADME.mdAPI Reference reflects the new pathsReferences
src/Dotnet.Samples.AspNetCore.WebApi/Controllers/PlayerController.cs(lines 127, 162, 207)README.md— API Reference section