forked from sergeytrasko/node-wsdl2swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
22 lines (19 loc) · 798 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var apiconnWsdl = require("apiconnect-wsdl");
var fs = require("fs");
var args = require('yargs').argv;
var target = args.target || '.';
if (!fs.existsSync(target)) {
fs.mkdirSync(target);
}
apiconnWsdl.getJsonForWSDL(args.wsdl).then(function (wsdls) {
var serviceData = apiconnWsdl.getWSDLServices(wsdls);
for (var item in serviceData.services) {
var serviceName = serviceData.services[item].service;
var wsdlId = serviceData.services[item].filename;
var wsdlEntry = apiconnWsdl.findWSDLForServiceName(wsdls, serviceName);
var swagger = apiconnWsdl.getSwaggerForService(wsdlEntry, serviceName, wsdlId);
fs.writeFile(target + '/' + serviceName + '.json', JSON.stringify(swagger))
}
}, function (error) {
console.log(error.message)
});