forked from theoomoregbee/sails-hook-swagger-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (47 loc) · 1.93 KB
/
index.js
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
/**
* Our hook
*/
var swaggerDoc = require("./lib/swaggerDoc");
module.exports = function (sails) {
return {
defaults: {
disabled: false,
__configKey__: {
swaggerJsonPath: sails.config.appPath + "/swagger/swagger.json",
parameters: { //we can add up custom parameters here
PerPageQueryParam: {
in: 'query',
name: 'perPage',
required: false,
type: 'integer',
description: 'This helps with pagination and when the limit is known for pagify'
}
},
blueprint_parameters: {list: [{$ref: '#/parameters/PerPageQueryParam'}]},//we can add custom blueprint action to parameters binding here, any specified overrides default created
swagger: {
swagger: '2.0',
info: {
title: 'Swagger Json',
description: 'This is a generated swagger json for your sails project',
termsOfService: 'http://example.com/terms',
contact: {
name: 'Theophilus Omoregbee',
url: 'http://github.com/theo4u',
email: '[email protected]'
},
license: {name: 'Apache 2.0', url: 'http://www.apache.org/licenses/LICENSE-2.0.html'},
version: '1.0.0'
},
host: 'localhost:1337',
basePath: '/',
externalDocs: {url: 'http://theophilus.ziippii.com'}
}
}
},
// Run when sails loads-- be sure and call `next()`.
initialize: function (next) {
swaggerDoc(sails, this);
return next();
}
};
};