-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added swagger tools to use swagger UI
but it can not load underscore.min.js, in node modules, I see lodash.min.js. Maybe it's time to update swagger express mw to 0.6.0 and use Sway instead of swagger tools. related issue #3
- Loading branch information
Showing
4 changed files
with
67 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
'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 config = { | ||
appRoot: __dirname // required config | ||
appRoot: __dirname // required config | ||
}; | ||
|
||
SwaggerExpress.create(config, function(err, swaggerExpress) { | ||
if (err) { throw err; } | ||
SwaggerExpress.create(config, function (err, swaggerExpress) { | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
// install middleware | ||
swaggerExpress.register(app); | ||
// add swagger-ui | ||
app.use(SwaggerUi(swaggerExpress.runner.swagger)); | ||
|
||
// install middleware | ||
swaggerExpress.register(app); | ||
|
||
var port = process.env.PORT || 10010; | ||
app.listen(port); | ||
var port = process.env.PORT || 10010; | ||
app.listen(port); | ||
|
||
if (swaggerExpress.runner.swagger.paths['/hello']) { | ||
console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott'); | ||
} | ||
if (swaggerExpress.runner.swagger.paths['/hello']) { | ||
console.log('try this:\ncurl http://127.0.0.1:' + port + '/api/v1/hello?name=Scott'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters