MCPcopy Create free account
hub / github.com/APIs-guru/aws2openapi / doit

Function doit

aws2openapi.js:13–95  ·  view source on GitHub ↗
(input, regionConfig)

Source from the content-addressed store, hash-verified

11var preferred = require('./preferred.json');
12
13function doit(input, regionConfig) {
14 var outputDir = (process.argv.length>3 ? process.argv[3] : './aws/');
15 if (!outputDir.endsWith('/')) outputDir += '/';
16 var outputYaml = (process.argv.length>4 ? (process.argv[4] == '-y') : false);
17
18 console.log(input);
19 var aws = require(path.resolve(input));
20 var options = {
21 regionConfig: regionConfig
22 };
23 try {
24 options.paginators = require(path.resolve(input.replace('.normal.','.paginators.')));
25 console.log(' Has paginators');
26 }
27 catch (ex) {}
28 try {
29 options.examples = require(path.resolve(input.replace('.normal.','.examples.')));
30 console.log(' Has examples version '+options.examples.version);
31 }
32 catch (ex) {}
33
34 // https://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-waiters.html
35 try {
36 options.waiters = require(path.resolve(input.replace('.normal.','.waiters2.')));
37 console.log(' Has waiters version '+options.waiters.version);
38 }
39 catch (ex) {}
40
41 var components = input.split('\\').join('/').split('/');
42 var filename = components[components.length-1];
43 options.filename = filename;
44 options.preferred = preferred;
45 filename = filename.replace('.normal.json','');
46 let prefix = helpers.extractServiceName(filename);
47 options.serviceName = prefix;
48
49 var result = aws2oa.convert(aws,options,function(err,openapi){
50 if ((err) && (Object.keys(err).length>0)) {
51 console.log(JSON.stringify(err));
52 }
53 if (openapi) {
54 oasv.validate(openapi, { laxurls: true, validateSchema: 'never', text: '{}' })
55 .then(options => {
56 })
57 .catch(ex => {
58 if (ex.options && ex.options.context) {
59 const errorLocation = ex.options.context.pop();
60 console.error('@',errorLocation);
61 }
62 console.error(aws.metadata.uid, ex.message);
63 process.exitCode = 1;
64 });
65
66 var version = filename.replace(prefix+'-','');
67
68 openapi.info["x-serviceName"] = prefix;
69
70 try {

Callers 1

aws2openapi.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected