Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Add support for OOP in controllers. #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions middleware/swagger-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ var getHandlerName = function (req) {

return handlerName;
};

function isObjectClass(obj) {
return Object.prototype.toString.call(obj) === '[object Object]';
}

var handlerCacheFromDir = function (dirOrDirs) {
var handlerCache = {};
var jsFileRegex = /\.(coffee|js)$/;
Expand All @@ -81,9 +86,9 @@ var handlerCacheFromDir = function (dirOrDirs) {

debug(' %s%s:',
path.resolve(path.join(dir, file)),
(_.isPlainObject(controller) ? '' : ' (not an object, skipped)'));
(isObjectClass(controller) ? '' : ' (not an object, skipped)'));

if (_.isPlainObject(controller)) {
if (isObjectClass(controller)) {
_.each(controller, function (value, name) {
var handlerId = controllerName + '_' + name;

Expand Down