Skip to content

[Feature] Align POST /routes contract with its upsert behaviour #4

@EnduranceCode

Description

@EnduranceCode

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

  • A dedicated PUT /routes/{id} endpoint is added for route updates
  • POST /routes becomes create-only and always returns HTTP 201
  • The RouteApi interface is updated to document both endpoints correctly
  • The RouteRestController implementation is updated accordingly
  • The RouteService interface and RouteServiceMain are updated if needed
  • Tests cover both the create and update paths
  • The project builds and all tests pass without errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI contract and endpoint issuesenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions