Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Fixes the case when you pass a bunch of controller files but only some of them contain jsdoc annotations.
eg: 

    app.use(swagger.init(app, {
        apiVersion: '1.0',
        ...,
        apis: fs.readdirSync('./controllers').map(function (filename) {
            return path.join(controllersPath, filename);
        }),
        ...
    }));
  • Loading branch information
relvao committed Apr 16, 2014
1 parent df8cc90 commit 6190d11
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/swagger-express/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ function parseJsDocs(file, fn) {
var fragments = js.match(regex);
var docs = [];

if (!fragments) {
fn(null, docs);
return;
}

for (var i = 0; i < fragments.length; i++) {
var fragment = fragments[i];
var doc = doctrine.parse(fragment, { unwrap: true });
Expand Down

0 comments on commit 6190d11

Please sign in to comment.