forked from Zir01/swag-ts-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (38 loc) · 1.44 KB
/
app.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
var swaggerService = require("./lib/SwaggerService");
var http = require("http");
exports.process = function (options) {
if (!options) {
console.error("Sorry. Please supply options with swaggerPath");
}
else {
http.get(options.swaggerPath, function (res) {
res.setEncoding("utf-8");
var swaggerString = "";
res.on("data", function (data) {
console.log("Swagger json found!");
swaggerString += data;
});
res.on("end", function () {
// swagger object coming from server
var swaggerObject = JSON.parse(swaggerString);
var opt = options;
opt.swaggerObject = swaggerObject;
// for backwards compatibility
if (options.moduleName) {
opt.clientModuleName = options.moduleName;
opt.modelModuleName = options.moduleName;
}
// for backwards compatibility
if (options.destination) {
opt.clientDestination = options.destination;
opt.interfaceDestination = options.destination;
}
var swagSrv = new swaggerService(opt);
swagSrv.process();
});
}).on("error", function (e) {
console.log("Error : " + e.message);
});
}
};
//# sourceMappingURL=app.js.map