Description
The POST /routes endpoint in RouteRestController.save() currently behaves as an upsert:
- If
routeDTO.id() is null, it creates a new route and returns HTTP 201 (Created)
- If
routeDTO.id() is not null, it updates the existing route and returns HTTP 200 (OK)
However, the RouteApi interface only documents a @ApiResponse(responseCode = "201"), implying a create-only operation. The OpenAPI contract does not reflect the update path or the possibility of a 200 response.
Files affected:
endurancetrio-app/src/main/java/com/endurancetrio/app/tracker/api/RouteApi.java
endurancetrio-app/src/main/java/com/endurancetrio/app/tracker/api/RouteRestController.java
Proposed approach:
Add a dedicated PUT /routes/{id} endpoint for updates and make POST /routes strictly create-only (always returning 201). This aligns with REST best practices and keeps the API contract clean and predictable.
Acceptance Criteria
Description
The
POST /routesendpoint inRouteRestController.save()currently behaves as an upsert:routeDTO.id()is null, it creates a new route and returns HTTP 201 (Created)routeDTO.id()is not null, it updates the existing route and returns HTTP 200 (OK)However, the
RouteApiinterface only documents a@ApiResponse(responseCode = "201"), implying a create-only operation. The OpenAPI contract does not reflect the update path or the possibility of a 200 response.Files affected:
endurancetrio-app/src/main/java/com/endurancetrio/app/tracker/api/RouteApi.javaendurancetrio-app/src/main/java/com/endurancetrio/app/tracker/api/RouteRestController.javaProposed approach:
Add a dedicated
PUT /routes/{id}endpoint for updates and makePOST /routesstrictly create-only (always returning 201). This aligns with REST best practices and keeps the API contract clean and predictable.Acceptance Criteria
PUT /routes/{id}endpoint is added for route updatesPOST /routesbecomes create-only and always returns HTTP 201RouteApiinterface is updated to document both endpoints correctlyRouteRestControllerimplementation is updated accordinglyRouteServiceinterface andRouteServiceMainare updated if needed