Skip to content

Commit

Permalink
fix: modify script
Browse files Browse the repository at this point in the history
Changes:
- adjust script according to suggestion: #1059 (comment)
  • Loading branch information
AnimeshKumar923 committed Jul 5, 2024
1 parent fd16aef commit caf79b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions scripts/validation/embedded-examples-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ const combinedData = extractCommentsAndExamples(markdownContent);
function applyUpdates(updates, baseDoc) {
updates.forEach(update => {
try {

// Handle root document case
if (jsonPointerPath === '') {
if (update.json_pointer === '') {
baseDoc = mergePatch.apply(baseDoc, update.example);
return;
}

// For non-root cases, use jsonpointer to get and set the correct location
const targetObject = jsonpointer.get(baseDoc, jsonPointerPath);
const targetObject = jsonpointer.get(baseDoc, update.json_pointer);
const updatedObject = mergePatch.apply(targetObject || {}, update.example);
jsonpointer.set(baseDoc, jsonPointerPath, updatedObject);
jsonpointer.set(baseDoc, update.json_pointer, updatedObject);

} catch (e) {
console.error(`\nError processing update for '${update.name}' at path '${update.json_pointer}'`, e);
Expand Down

0 comments on commit caf79b5

Please sign in to comment.