Hi!

So I've created several API documentations and want to serve them under 
different URLs,  the trouble I'm having is running multiple swagger express 
instances under the same port (bad!)

'use strict';

var SwaggerExpress = require('swagger-express-mw');
var SwaggerUi = require('swagger-tools/middleware/swagger-ui');
var app = require('express')();
module.exports = app; // for testing
var configs = ['client', 'admin', 's2s', 'delegation'];

for(var i in configs) {
  var config = {
    appRoot: __dirname, // required config
    swaggerFile: __dirname + "/api/swagger/" + configs[i] + "_swagger.yaml",
  }
  SwaggerExpress.create(config, function(err, swaggerExpress) {
    if (err) { throw err; }

    // enable SwaggerUI
    var options = {
      apiDocs: "/api-" + configs[i] + "-docs",
      swaggerUi: "/" + configs[i] + "-docs"
    }
    app.use(SwaggerUi(swaggerExpress.runner.swagger, options));

    // install middleware
    swaggerExpress.register(app);

    var port = process.env.PORT || 10010;
    app.listen(port);

    console.log("Swagger 2.0 instance of the client api");
  });
}


Please point me in the right direction to run several documents at once.

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to