Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function generateEditingResolvedModel(doc, type) {
const resolver = amf.Core.resolver(type);
doc = resolver.resolve(doc, 'editing');
const generator = amf.Core.generator('AMF Graph', 'application/ld+json');
const opts = amf.render.RenderOptions().withSourceMaps.withCompactUris;
return generator.generateString(doc, opts);
}
_save(doc, file) {
this.logger.info('Generating json-ld model...');
const opts = amf.render.RenderOptions().withSourceMaps.withCompactUris;
const generator = amf.Core.generator('AMF Graph', 'application/ld+json');
const start = Date.now();
return generator.generateString(doc, opts)
.then((data) => {
const time = Date.now() - start;
this.logger.info(`Model ready in ${time} milliseconds`);
this.logger.info('Storing API data model to file: ' + file);
const dir = path.dirname(file);
return fs.ensureDir(dir)
.then(() => fs.writeFile(file, data, 'utf8'));
});
}