-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathswagger.js
More file actions
62 lines (59 loc) · 1.53 KB
/
swagger.js
File metadata and controls
62 lines (59 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Altered version of sample usage code
* https://www.npmjs.com/package/express-swagger-generator#usage
*
* This will add the /api-docs route to the express app instance.
*
* To use, alter the options object as needed and call the exported
* function as follows:
*
* ```js
* const express = require('express');
* // Prepare the express app
* const app = express();
* // Add the swagger /api-docs route to the server
* const swagger = require('../docs/swagger');
* swagger(app);
* ```
*/
'use strict';
const swaggerGenerator = require('express-swagger-generator');
let options = {
swaggerDefinition: {
info: {
description: 'CaseHawk API Server',
title: 'CaseHawk API Server',
version: '1.0.0',
},
// host: 'CHANGE_THIS.herokuapp.com', // TODO: Deployment Link Here
host: 'localhost:4000',
basePath: '/',
produces: [
"application/json",
"application/xml"
],
schemes: ['http', 'https'],
securityDefinitions: {
JWT: {
type: 'apiKey',
in: 'header',
name: 'Authorization',
description: "",
},
basicAuth: {
type: 'basic',
in: 'header',
name: 'Authorization',
description: "",
}
}
},
basedir: __dirname, //app absolute path
files: ['../lib/**/*.js', '../src/**/*.js'] //Path to the API handle folder
};
/**
* Add the /api-docs route to the express app instance.
*
* @param {Express} app - Your express app instance
*/
module.exports = app => swaggerGenerator(app)(options);