Skip to content

feat(core): add patch endpoint for partial update on properties - #142

Open
RVANDO12 wants to merge 2 commits into
mainfrom
feat/patch/entity
Open

feat(core): add patch endpoint for partial update on properties#142
RVANDO12 wants to merge 2 commits into
mainfrom
feat/patch/entity

Conversation

@RVANDO12

@RVANDO12 RVANDO12 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

PR Description

What this PR Provides

  • Adds support for partially updating an entity via a new PATCH endpoint (PATCH /api/v1/entities/{templateIdentifier}/{entityIdentifier}).
  • Preserves omitted fields in the request body, merging provided properties and relations into the existing entity state.
  • Updates API controller, DTO definitions, request mapping, OpenAPI specification, and integration tests to cover partial update workflows.

Review

The reviewer must double-check these points:

  • The reviewer has tested the feature
  • The reviewer has reviewed the implementation of the feature
  • The documentation has been updated
  • The feature implementation respects the Technical Doc / ADR previously produced

How to test

Initial State

Ensure the web-service template and entity web-api-1 exist in idp-back with properties such as applicationName set to catalog-api and port set to 8080.

What and How to Test

Execute a PATCH HTTP request against the entity resource updating only the port field:

curl -X PATCH http://localhost:8084/api/v1/entities/web-service/web-api-1 \
  -H "Content-Type: application/json" \
  -d '{"properties": {"port": "9090"}}'

Expected Results

  • The endpoint returns HTTP 200 OK with the updated EntityDtoOut schema.
  • The property port is updated to "9090".
  • All omitted properties (e.g., applicationName) and relations remain unchanged.

Breaking changes (if any)

  • N/A

@github-code-quality

github-code-quality Bot commented Sep 9, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Java

Java / code-coverage/jacoco

The overall line coverage in commit 9dd7feb in the feat/patch/entity branch remains at 91%, unchanged from commit 2054615 in the main branch.

Show a line coverage summary of the most impacted files.
File main 2054615 feat/patch/entity 9dd7feb +/-
com/decathlon/i...Controller.java 100% 100% 0%
com/decathlon/i...PatchDtoIn.java 0% 0% 0%
com/decathlon/i...toInMapper.java 100% 100% 0%
com/decathlon/i...ntityPatch.java 0% 100% +100%

Updated September 09, 2026 13:11 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The PATCH mapping/validation flow appears incompatible with “omit fields to preserve them” semantics (notably omitting name), and the main documented PATCH use-case isn’t currently enforced by the integration test as written.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new REST PATCH endpoint to partially update entities, aiming to preserve omitted fields while merging provided properties/relations into the existing entity state. This extends the Entities Management API and updates the documentation and test fixtures to support the new workflow.

Changes:

  • Added PATCH /api/v1/entities/{templateIdentifier}/{entityIdentifier} to the API controller, plus request DTO + mapper support.
  • Updated CORS configuration and OpenAPI (static swagger) to expose the new operation.
  • Expanded integration tests and seeded test data to cover partial update scenarios.
File summaries
File Description
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityController.java Adds the new PATCH endpoint wiring into the domain service.
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/dto/in/EntityPatchDtoIn.java Introduces a request DTO for partial entity updates.
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/mapper/entity/EntityDtoInMapper.java Adds mapping from PATCH DTO to the domain model.
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/configuration/SwaggerDescription.java Adds Swagger strings for PATCH endpoint summary/description and schema description.
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/configuration/SecurityConfiguration.java Updates CORS allowed methods to include PATCH.
docs/src/static/swagger.yaml Documents the PATCH operation and EntityPatchDtoIn schema in the published OpenAPI.
docs/src/concepts/entities.md Documents how to use PATCH for partial updates.
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityControllerTest.java Adds integration tests for PATCH behavior and adjusts search expectations.
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/mapper/entity/EntityDtoInMapperTest.java Adds unit coverage for the new patch DTO mapping method.
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityTemplateControllerTest.java Updates expected template counts due to the new patch-test template fixture.
src/test/resources/db/test/R__1_Insert_test_data.sql Adds a minimal patch-test template and relation/property definitions for patch scenarios.
src/test/resources/db/test/R__2_Insert_entities_test_data.sql Seeds an entity fixture (web-api-patch-1) used by PATCH integration tests.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/src/concepts/entities.md Outdated
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants