Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static loadFromFile(apiJsonFilePath: string): ApiJsonFile {
const docPackage: IApiPackage = JsonFile.loadAndValidateWithCallback(apiJsonFilePath, ApiJsonGenerator.jsonSchema,
(errorInfo: IJsonSchemaErrorInfo) => {
const errorMessage: string
= path.basename(apiJsonFilePath) + ' does not conform to the expected schema.' + os.EOL
+ '(Was it created by an incompatible release of API Extractor?)' + os.EOL
+ errorInfo.details;
console.log(os.EOL + 'ERROR: ' + errorMessage + os.EOL + os.EOL);
throw new Error(errorMessage);
}
);
const packageName: string = path.basename(apiJsonFilePath).replace(/\.api\.json$/i, '');
return new ApiJsonFile(packageName, docPackage);
}