Skip to content

Commit

Permalink
configure paths from the basePath version
Browse files Browse the repository at this point in the history
  • Loading branch information
ajo2995 committed Mar 2, 2016
1 parent 31a5f64 commit 0471627
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
version: "0.50.0"
title: Gramene API for release 50
# basePath prefixes all resource paths
basePath: /
basePath: /v50
# during dev, should point to your local machine
#host: localhost:10010/{basePath}
#
Expand Down
10 changes: 6 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ var config = {
SwaggerExpress.create(config, function (err, swaggerExpress) {
if (err) { throw err; }

var basePath = swaggerExpress.runner.swagger.basePath;
// define routes for documentation
app.get('/', function (req, res, next) { // redirect to /docs with the correct schema
res.redirect('/docs?url=/swagger');
app.get(basePath, function (req, res, next) { // redirect to /docs with the correct schema
res.redirect(basePath+'/docs?url='+basePath+'/swagger');
});

app.use('/docs', express.static('node_modules/swagger-ui/dist'));
app.use(basePath+'/docs', express.static('node_modules/swagger-ui/dist'));

// install swagger server middleware
swaggerExpress.register(app);

// start it up
var port = process.env.PORT || 10011;
var version = +basePath.match(/\d+/);
var port = process.env.PORT || 10000 + version;
app.listen(port);

console.log('Listening on', port);
Expand Down

0 comments on commit 0471627

Please sign in to comment.