Skip to content

Commit

Permalink
fix slow hasFileType check
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob McGuinness committed Sep 19, 2018
1 parent c38af0a commit 1f8a812
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
7 changes: 4 additions & 3 deletions lib/paths.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Hoek = require('hoek');
const Joi = require('joi');
const fastSafeStringify = require('fast-safe-stringify');

const Parameters = require('../lib/parameters');
const Definitions = require('../lib/definitions');
Expand Down Expand Up @@ -386,8 +385,10 @@ internals.overload = function (base, priority) {
* @return {Boolean}
*/
internals.hasFileType = function (route) {

let routeString = fastSafeStringify(route);
const routeString = JSON.stringify(route, (key, value) => {
// _currentJoi is a circular reference, introduced in Joi v11.0.0
return key === '_currentJoi' ? undefined : value;
});
return routeString.indexOf('swaggerType') > -1;
};

Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
},
"dependencies": {
"boom": "^7.1.1",
"fast-safe-stringify": "^1.2.3",
"handlebars": "^4.0.11",
"hoek": "^5.0.3",
"http-status": "^1.0.1",
Expand Down

0 comments on commit 1f8a812

Please sign in to comment.