Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ module.exports = {
thisPathObject,
thisPathCount,
len,
i;
i,
segmentKey;

//if a particular path has MORE than 1 props, make it a folder - always
//how to detemine subfolders?
Expand Down Expand Up @@ -417,8 +418,9 @@ module.exports = {
treeNode = tree;

for (i = 0; i < len; i++) {
if (!treeNode.children[thisPath[i]]) {
treeNode.children[thisPath[i]] = {
segmentKey = thisPath[i].toUpperCase();
if (!treeNode.children[segmentKey]) {
treeNode.children[segmentKey] = {
name: thisPath[i],
requestCount: 0,
children: {},
Expand All @@ -427,8 +429,8 @@ module.exports = {
};
}

treeNode.children[thisPath[i]].requestCount += thisPathCount;
treeNode = treeNode.children[thisPath[i]];
treeNode.children[segmentKey].requestCount += thisPathCount;
treeNode = treeNode.children[segmentKey];
}

// loop complete. Add the children here
Expand Down
22 changes: 22 additions & 0 deletions test/unit/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ describe('The converter must identify invalid specs: ', function () {

//Helpers
describe('Helpers', function () {
it('getTreeFromPaths Routes should not be case sensitive', function() {
var json = {
paths:{
"/Foo/bar":{"get":{}},
"/FOO/baz":{"get":{}}
}
},
tree = Helpers.getTreeFromPaths(json);

var names = [];
for (var child in tree.children) {
if (tree.children.hasOwnProperty(child)) {
names.push(tree.children[child].name);
console.log(child);
}
}
expect(names.length).to.equal(1);
expect(names[0]).to.equal("Foo");
expect(tree.children["FOO"].children["BAR"].name).equals("bar");
expect(tree.children["FOO"].children["BAZ"].name).equals("baz");
});

it('getBasePath should return the correct basePath', function() {
var swagger = {
host: 'getpostman.com',
Expand Down