wordnik/swagger-node-express — pull request #83 by tcbeutler (2013-12-10 20:11:43+00:00)
Title: Allow swagger 'action' functions to access next() from Express.

To use Express middleware that does post-processing, route verbs need to declared using the midddleware syntax with the third parameter callback. An example use for this might be final formatting of the response before send is called.

Action would then have access to something like this:

'action': function (req, res, next) {
res.body = getResource();
next();
}

When configuring the express middleware stack, post-processors can be defined.

app.use(app.router);
app.use(function (req, res, next) {
console.log('Post-processing done here.');
res.send(formatResponse(res));
});

This change has no negative side effects, as omitting the third parameter allows for swagger to work exactly as it did before.

'action': function (req, res, next) {
res.send(getResource());
}