Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_validate(doc, type) {
this.logger.info('API parsed.');
this.logger.info('Validating API...');
let validateProfile;
switch (type) {
case 'RAML 1.0': validateProfile = amf.ProfileNames.RAML; break;
case 'RAML 0.8': validateProfile = amf.ProfileNames.RAML08; break;
case 'OAS 2.0':
case 'OAS 3.0':
validateProfile = amf.ProfileNames.OAS;
break;
}
return amf.AMF.validate(doc, validateProfile)
.then((report) => {
if (!report.conforms) {
this.logger.warn(report.toString());
} else {
this.logger.info('API valid.');
}
return doc;
});
}