Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titlexpath with incorrect JSON payload

xpath: /bookstore/categories[@code=1]

Incorrect JSON payload:

Code Block
languagenone
{
  "code": 1,                      //parent node data should not be in the payload
  "name": "Kids",                      
  "books": [
    {
      "title": "Matilda",
      "editions": [1988, 2000, 2024],
      "price": 25
    }
  ]
}

...

Expand
titleData fetched from DB after partial update
Code Block
{
    "code": "1",
    "name": "Children",                        //not updated
    "books": [
      {
	 	"title": "Matilda",
        "lang": "English",
        "editions": [1988, 2000, 2024],       //updated
		"price": 25							  //updated
       }
    ]
  }

Proposed Solution for Scenario 1:

The proposed solution is to drop the support for using parent node xpath in the request and instead the exact xpath of the data node being updated should be provided in the request.

Apart from this based on the RESTful rules, an additional check should be put in place to first fetch the existing data from the database and verify that it exists and is valid before performing the PATCH operation.

Scenario 2: API does not update child nodes

...

Expand
titleOriginal Data
Code Block
languagejson
{
  "categories": {
    "code": "1",
    "name": "Children",
    "books": [
      {
	 	"title": "Matilda",
        "lang": "English",
        "price": 200,
        "editions": [1988,2000]
      }
    ]
  }
}

...

Expand
titleData fetched from DB after partial update
Code Block
{
  "categories": {
    "code": "1",
    "name": "Kids",                 //updated
    "books": [
      {
        "title": "Matilda", 
     	"lang": "English",
        "price": 200,              //not updated
		"editions": [1988,2000]    //not updated    
		}
    ]
  }
}

Proposed Solution for Scenario 2

  • Solution 1: Limit the update operation to one Data Node at a time

  • Solution 2: Add support to update multiple data nodesSolution 1: Limit the update operation to one Data Node at a time

  • Solution 2: Add support to update multiple data nodes

Expected Behavior

The expected behavior should be as follows:

...