Skip to content

Commit

Permalink
Remove swagger-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
chdanielmueller committed Jun 9, 2015
1 parent f63a68b commit 1ddc012
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
20 changes: 5 additions & 15 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Dependencies
var express = require('express');
var bodyParser = require('body-parser');
var swaggerTools = require('swagger-tools');
var routes = require('./routes');
var swaggerJSDoc = require('../');

Expand Down Expand Up @@ -42,20 +41,11 @@ var options = {
var swaggerSpec = swaggerJSDoc(options);


// Swagger Tools Options
var swaggerToolsUIOptions = {
apiDocs: '/api-docs.json',
swaggerUi: '/docs',
};


// Initialize the Swagger middleware
swaggerTools.initializeMiddleware(swaggerSpec,
function(middleware) {
// Serve the Swagger documents and Swagger UI
app.use(middleware.swaggerUi(swaggerToolsUIOptions));
}
);
// Serve swagger docs the way you like (Recommendation: swagger-tools)
app.get('/api-docs.json', function(req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerSpec);
});


// Set up the routes
Expand Down
20 changes: 6 additions & 14 deletions example/routes.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
'use strict';


// Handler for the Homepage
function rootHandler(req, res) {
res.send('Hello World!');
}


// Handler for Login
function loginHandler(req, res) {
res.json(req.body);
}


// Sets up the routes.
module.exports.setup = function(app) {

Expand All @@ -26,7 +14,9 @@ module.exports.setup = function(app) {
* 200:
* description: hello world
*/
app.get('/', rootHandler);
app.get('/', function(req, res) {
res.send('Hello World!');
});


/**
Expand All @@ -51,5 +41,7 @@ module.exports.setup = function(app) {
* 200:
* description: login
*/
app.post('/login', loginHandler);
app.post('/login', function(req, res) {
res.json(req.body);
});
};
6 changes: 3 additions & 3 deletions external.jsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

/**
* Various tools for using and integrating with Swagger.
* @external module:swagger-tools
* Swagger JSON/YAML parser and validator for Node and browsers
* @external module:swagger-parser
* @global
* @see https://www.npmjs.com/package/swagger-tools
* @see https://www.npmjs.com/package/swagger-parser
* @license MIT
*/
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"mocha": "^2.2.5",
"mocha-jscs": "^1.1.0",
"mocha-jshint": "^2.2.3",
"supertest": "^1.0.1",
"swagger-tools": "^0.8.7"
"supertest": "^1.0.1"
}
}

0 comments on commit 1ddc012

Please sign in to comment.