Skip to content

Commit 4be9b8d

Browse files
committed
add the tests
1 parent 980f335 commit 4be9b8d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

fittings/swagger_raw.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = function create(fittingDef, bagpipes) {
4646
};
4747

4848
function filterKeysRecursive(object, dropTagRegex, privateTags) {
49-
if (object && 'object' == typeof object)) {
49+
if (_.isPlainObject(object)) {
5050
if (_.any(privateTags, function(tag) { return object[tag]; })) {
5151
object = undefined;
5252
} else {
@@ -66,6 +66,12 @@ function filterKeysRecursive(object, dropTagRegex, privateTags) {
6666
});
6767
return result;
6868
}
69+
} else if (Array.isArray(object) ) {
70+
object = object.reduce(function(reduced, value) {
71+
var v = filterKeysRecursive(value, dropTagRegex, privateTags);
72+
if (v !== undefined) reduced.push(v);
73+
return reduced
74+
}, [])
6975
}
7076
return object;
7177
}

test/assets/project/api/swagger/swagger.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ paths:
2222
description: The name of the person to whom to say hello
2323
required: false
2424
type: string
25+
x-remove-me: lol
2526
responses:
2627
200:
2728
description: Success

test/fittings/swagger_raw.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ describe('swagger_raw', function() {
1818

1919
var filteredSwagger = _.cloneDeep(swagger);
2020
delete(filteredSwagger.paths['/invalid_header']);
21+
delete(filteredSwagger.paths['/hello'].get.parameters[0]['x-remove-me'])
2122

2223
// hokey algorithm, but at least it's different than the one it's testing
2324
var OMIT = ['x-swagger-router-controller', 'x-swagger-pipe', 'x-hidden', 'x-private', 'x-controller-interface'];

0 commit comments

Comments
 (0)