forked from Mermade/widdershins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (30 loc) · 891 Bytes
/
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
'use strict';
const openapi2 = require('./openapi2.js');
const openapi3 = require('./openapi3.js');
const asyncapi1 = require('./asyncapi1.js');
const semoasa = require('./semoasa.js');
const apiblueprint = require('./apiblueprint.js');
function convert(api, options, callback) {
options.samplerErrors = new Map();
if (typeof api === 'string') {
apiblueprint.convert(api, options, callback);
}
else if (api.swagger) {
openapi2.convert(api, options, callback);
}
else if (api.openapi) {
openapi3.convert(api, options, callback);
}
else if (api.asyncapi) {
asyncapi1.convert(api, options, callback);
}
else if (api.openapiExtensionFormat) {
semoasa.convert(api, options, callback);
}
else {
callback(new Error('Unrecognised input format'));
}
}
module.exports = {
convert: convert
};