-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
41 lines (34 loc) · 1.16 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
'use strict';
const defaults = require('defaults-deep');
const path = require('path');
module.exports = (templateSetOptions) => {
const options = defaults(templateSetOptions || {}, {
definitions: './definitions',
controllers: './controllers',
defsRelativeToController: '../definitions',
operations: ['get', 'put', 'post', 'delete'],
controllerSplitBy: 'x-swagger-router-controller',
implementationPath: null,
});
// Mandatory parameter.
if (!options.implementationPath) {
throw new Error('Cannot load template set: you must specify the implementationPath!');
}
const result = {
perPath: {},
perDefinition: {}
};
const definitionKey = path.join(__dirname, 'perDefinition', 'es6-definition.js');
result.perDefinition[definitionKey] = {
target: options.definitions,
}
const pathKey = path.join(__dirname, 'perPath', 'es6-controller-stub.js');
result.perPath[pathKey] = {
target: options.controllers,
operations: options.operations,
groupBy: options.controllerSplitBy,
defsRelativeToController: options.defsRelativeToController,
implementationPath: options.implementationPath,
};
return result;
};