File tree 4 files changed +15
-34
lines changed
4 files changed +15
-34
lines changed Original file line number Diff line number Diff line change 4
4
// Dependencies
5
5
var express = require ( 'express' ) ;
6
6
var bodyParser = require ( 'body-parser' ) ;
7
- var swaggerTools = require ( 'swagger-tools' ) ;
8
7
var routes = require ( './routes' ) ;
9
8
var swaggerJSDoc = require ( '../' ) ;
10
9
@@ -42,20 +41,11 @@ var options = {
42
41
var swaggerSpec = swaggerJSDoc ( options ) ;
43
42
44
43
45
- // Swagger Tools Options
46
- var swaggerToolsUIOptions = {
47
- apiDocs : '/api-docs.json' ,
48
- swaggerUi : '/docs' ,
49
- } ;
50
-
51
-
52
- // Initialize the Swagger middleware
53
- swaggerTools . initializeMiddleware ( swaggerSpec ,
54
- function ( middleware ) {
55
- // Serve the Swagger documents and Swagger UI
56
- app . use ( middleware . swaggerUi ( swaggerToolsUIOptions ) ) ;
57
- }
58
- ) ;
44
+ // Serve swagger docs the way you like (Recommendation: swagger-tools)
45
+ app . get ( '/api-docs.json' , function ( req , res ) {
46
+ res . setHeader ( 'Content-Type' , 'application/json' ) ;
47
+ res . send ( swaggerSpec ) ;
48
+ } ) ;
59
49
60
50
61
51
// Set up the routes
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
4
- // Handler for the Homepage
5
- function rootHandler ( req , res ) {
6
- res . send ( 'Hello World!' ) ;
7
- }
8
-
9
-
10
- // Handler for Login
11
- function loginHandler ( req , res ) {
12
- res . json ( req . body ) ;
13
- }
14
-
15
-
16
4
// Sets up the routes.
17
5
module . exports . setup = function ( app ) {
18
6
@@ -26,7 +14,9 @@ module.exports.setup = function(app) {
26
14
* 200:
27
15
* description: hello world
28
16
*/
29
- app . get ( '/' , rootHandler ) ;
17
+ app . get ( '/' , function ( req , res ) {
18
+ res . send ( 'Hello World!' ) ;
19
+ } ) ;
30
20
31
21
32
22
/**
@@ -51,5 +41,7 @@ module.exports.setup = function(app) {
51
41
* 200:
52
42
* description: login
53
43
*/
54
- app . post ( '/login' , loginHandler ) ;
44
+ app . post ( '/login' , function ( req , res ) {
45
+ res . json ( req . body ) ;
46
+ } ) ;
55
47
} ;
Original file line number Diff line number Diff line change 15
15
*/
16
16
17
17
/**
18
- * Various tools for using and integrating with Swagger.
19
- * @external module:swagger-tools
18
+ * Swagger JSON/YAML parser and validator for Node and browsers
19
+ * @external module:swagger-parser
20
20
* @global
21
- * @see https://www.npmjs.com/package/swagger-tools
21
+ * @see https://www.npmjs.com/package/swagger-parser
22
22
* @license MIT
23
23
*/
Original file line number Diff line number Diff line change 39
39
"mocha" : " ^2.2.5" ,
40
40
"mocha-jscs" : " ^1.1.0" ,
41
41
"mocha-jshint" : " ^2.2.3" ,
42
- "supertest" : " ^1.0.1" ,
43
- "swagger-tools" : " ^0.8.7"
42
+ "supertest" : " ^1.0.1"
44
43
}
45
44
}
You can’t perform that action at this time.
0 commit comments