@sap/cds-dk
Version:
Command line client and development toolkit for the SAP Cloud Application Programming Model
34 lines (27 loc) • 798 B
JavaScript
const ParserContext = require("./parserContext");
const cdsDkVersion = require("../../../package.json").version;
function importAsyncAPI(input) {
const context = new ParserContext(input);
return convertToCSN(context);
}
function convertToCSN(context) {
const csn = {
meta: {
creator: `cds-dk ${cdsDkVersion}`
},
$version: '2.0',
definitions: {}
};
Object.entries(context.services).forEach(([key, value]) => {
const events = value.events;
const types = value.types;
delete value.events;
delete value.types;
csn.definitions[key] = value;
Object.assign(csn.definitions, events, types);
});
return csn;
}
module.exports = {
importAsyncAPI
}