Problem
The API supports PUT for player updates, which requires sending the complete player payload even when only one or two fields need to change. A PATCH endpoint would allow callers to update specific fields without providing the entire resource.
Proposed Solution
Add PATCH /players/{squadNumber} for partial updates (following the existing PUT and DELETE URL convention in this repo).
- All fields are patchable except
squadNumber (natural key, present in the URL path) and id (UUID surrogate key).
- Only the fields present in the request body are updated; absent fields retain their current values.
- If the request body includes
squadNumber or id, the endpoint returns 400 Bad Request.
Suggested Approach
- DTO — Add
PlayerPatchDTO in the models package with all patchable fields as nullable (e.g. String, Boolean). Exclude squadNumber and id. Annotate with @JsonInclude(JsonInclude.Include.NON_NULL) so absent fields serialize cleanly.
- Service — Add
boolean patch(Integer squadNumber, PlayerPatchDTO dto) in PlayersService. Retrieve the existing player, apply only the non-null fields from the DTO, then persist.
- Controller — Add
@PatchMapping("/players/{squadNumber}") in PlayersController. Check for forbidden fields (squadNumber, id) → 400. Look up player → 404 if missing. Return ResponseEntity<Void> with HttpStatus.NO_CONTENT on success.
- Tests — Add unit tests following existing naming conventions.
Acceptance Criteria
References
Problem
The API supports
PUTfor player updates, which requires sending the complete player payload even when only one or two fields need to change. APATCHendpoint would allow callers to update specific fields without providing the entire resource.Proposed Solution
Add
PATCH /players/{squadNumber}for partial updates (following the existingPUTandDELETEURL convention in this repo).squadNumber(natural key, present in the URL path) andid(UUID surrogate key).squadNumberorid, the endpoint returns400 Bad Request.Suggested Approach
PlayerPatchDTOin the models package with all patchable fields as nullable (e.g.String,Boolean). ExcludesquadNumberandid. Annotate with@JsonInclude(JsonInclude.Include.NON_NULL)so absent fields serialize cleanly.boolean patch(Integer squadNumber, PlayerPatchDTO dto)inPlayersService. Retrieve the existing player, apply only the non-null fields from the DTO, then persist.@PatchMapping("/players/{squadNumber}")inPlayersController. Check for forbidden fields (squadNumber,id) →400. Look up player →404if missing. ReturnResponseEntity<Void>withHttpStatus.NO_CONTENTon success.Acceptance Criteria
PATCH /players/{squadNumber}is implementedsquadNumberandidare patchable204 No Contenton success400 Bad Requestif the body containssquadNumberorid400 Bad Requeston field validation failure404 Not Foundwhen no player has that squad numberCHANGELOG.mdupdatedReferences
@PatchMapping