Description
If you build a JSON patch descriptor that uses PatchBuilder.applyLibraryValues, the resulting patch descriptor uses the property name "value" instead of "$value" when passing the values. The patch is OK if there are no user-supplied parameters involved.
For example, this code:
JSONDocumentManager jdm = client.newJSONDocumentManager();
DocumentPatchBuilder pb = jdm.newPatchBuilder();
pb.pathLanguage(DocumentPatchBuilder.PathLanguage.XPATH);
pb.library("", "/ext/marklogic/patch/apply/my-lib.sjs");
pb.replaceApply("/inventory[name eq 'orange']/price", pb.call().applyLibrary("dbl"));
pb.replaceApply("/inventory[name eq 'pear']/price",
pb.call().applyLibraryValues("min", 18, 21));
System.out.println(pb.build().toString());
Generates the following patch. Notice the items of the "content" array near the end of the "min" replace descriptor. Those array item property names should be "$value", not "value". There's also a comma missing between the items. I assume that is a bug in the serialization, but IDK if that affects the request or just my lazy attempt to dump out the patch.
{ "pathlang":"xpath",
"patch":[
{ "replace-library":{
"ns":"",
"at":"/ext/marklogic/patch/apply/my-lib.sjs"
}},
{ "replace":{
"select":"/inventory[name eq 'orange']/price",
"apply":"dbl"
}},
{ "replace":{
"select":"/inventory[name eq 'pear']/price",
"apply":"min",
"content":[{"value":18}{"value":21}]
}}
]
}
There does not appear to be a test that exercises the applyLibrary feature for JSON patches, though perhaps I just missed it.