Skip to content

Commit 0d8a765

Browse files
authored
Merge pull request #135 from amarzavery/wf2
fixed #134
2 parents 4147bb5 + 86bd47c commit 0d8a765

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### 07/03/2017 0.4.6
2+
- Fixed issue #134
3+
4+
### 06/26/2017 0.4.5
5+
- Added support to generate wireformat as a YAML doc
6+
- Improved the format to specify request body for a in a request using curl.

lib/util/utils.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,35 @@ exports.parseJsonWithPathFragments = function parseJsonWithPathFragments() {
303303
*/
304304
exports.mergeObjects = function mergeObjects(source, target) {
305305
Object.keys(source).forEach(function (key) {
306-
target[key] = source[key];
306+
if (Array.isArray(source[key])) {
307+
if (target[key] && !Array.isArray(target[key])) {
308+
throw new Error(`Cannot merge ${key} from source object into target object because the same property in target object is not (of the same type) an Array.`);
309+
}
310+
if (!target[key]) {
311+
target[key] = [];
312+
}
313+
target[key] = exports.mergeArrays(source[key], target[key]);
314+
} else {
315+
target[key] = source[key];
316+
}
317+
});
318+
return target;
319+
}
320+
321+
/*
322+
* Merges source array into the target array
323+
* @param {array} source The array that needs to be merged
324+
*
325+
* @param {array} target The array to be merged into
326+
*
327+
* @returns {array} target - Returns the merged target array.
328+
*/
329+
exports.mergeArrays = function mergeArrays(source, target) {
330+
if (!Array.isArray(target) || (!Array.isArray(source))) {
331+
return target;
332+
}
333+
source.forEach((item) => {
334+
target.push(item);
307335
});
308336
return target;
309337
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oav",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"author": {
55
"name": "Microsoft Corporation",
66
"email": "[email protected]",

0 commit comments

Comments
 (0)