Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run() {
let msg = 'Generating API model from ' + this.apiFile;
msg += ' using ' + this.apiType + ' parser';
this.logger.info(msg);
amf.plugins.document.WebApi.register();
amf.plugins.document.Vocabularies.register();
amf.plugins.features.AMFValidation.register();
return amf.Core.init()
.then(() => this.gaUsage())
.then(() => this._parse(this.apiFile, this.apiType))
.then((doc) => this._validate(doc, this.apiType))
.then((doc) => this._resolve(doc, this.apiType))
.then((doc) => this._save(doc, this.output));
}
/**
run() {
let msg = 'Generating API model from ' + this.apiFile;
msg += ' using ' + this.apiType + ' parser';
this.logger.info(msg);
amf.plugins.document.WebApi.register();
amf.plugins.document.Vocabularies.register();
amf.plugins.features.AMFValidation.register();
return amf.Core.init()
.then(() => this.gaUsage())
.then(() => this._parse(this.apiFile, this.apiType))
.then((doc) => this._validate(doc, this.apiType))
.then((doc) => this._resolve(doc, this.apiType))
.then((doc) => this._save(doc, this.output));
}
/**
const amf = require('amf-client-js');
amf.plugins.document.WebApi.register();
amf.plugins.document.Vocabularies.register();
amf.plugins.features.AMFValidation.register();
/**
* Parses AMF ld+json model to AMF document.
* The model has to be unresolved.
*
* @param {String} model
* @return {Promise} AMF document.
*/
function modelToDoc(model) {
const parser = amf.Core.parser('AMF Graph', 'application/ld+json');
return parser.parseStringAsync(model);
}
/**
* Generates resolved AMF model using editing pipeline (required by API console).
* @param {Object} doc Parsed API document to AMF object.
const amf = require('amf-client-js');
amf.plugins.document.WebApi.register();
amf.plugins.document.Vocabularies.register();
amf.plugins.features.AMFValidation.register();
/**
* Parses AMF ld+json model to AMF document.
* The model has to be unresolved.
*
* @param {String} model
* @return {Promise} AMF document.
*/
function modelToDoc(model) {
const parser = amf.Core.parser('AMF Graph', 'application/ld+json');
return parser.parseStringAsync(model);
}
/**
* Generates resolved AMF model using editing pipeline (required by API console).
* @param {Object} doc Parsed API document to AMF object.
* @param {String} type API original type (RAML 1.0, OAS 2.0, etc)
* @return {Promise} A promise resolved to AMF object.