Updating via Patch Document

Given an entity, i.e. an Account, we can define a JSON Patch document for describing some changes that we want to perform.

Entity’s attributes that could be used for partial updates are usually the same as the ones required for the creation of the entity, e.g. the accountPostDto model for POST /api/accounts.

For example, the following JSON Patch document can be used to PATCH /api/accounts/{accountId} method to update the account’s name and ordering enabled attribute (add and replace operations have the same impact here).

1 2 3 4 5 6 7 8 9 10 11 12 [ { "op": "add", "path": "/name", "value": "Barry" }, { "op": "replace", "path": "/orderingEnabled", "value": "true" } ]

Another example given below resets the account’s credit limit to its default value (0) using the remove operation.

1 2 3 4 5 6 [ { "op": "remove", "path": "/name" } ]