@microsoft/api-extractor
Version:
Validate, document, and review the exported API for a TypeScript library
31 lines • 1.32 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const node_core_library_1 = require("@microsoft/node-core-library");
/**
* Support for loading the *.api.json file.
*
* @public
*/
class ApiJsonFile {
/**
* Loads an *.api.json data file, and validates that it conforms to the api-json.schema.json
* schema.
*/
static loadFromFile(apiJsonFilePath) {
return node_core_library_1.JsonFile.loadAndValidateWithCallback(apiJsonFilePath, ApiJsonFile.jsonSchema, (errorInfo) => {
const errorMessage = path.basename(apiJsonFilePath) + ' does not conform to the expected schema.\n'
+ '(Was it created by an incompatible release of API Extractor?)\n'
+ errorInfo.details;
throw new Error(errorMessage);
});
}
}
/**
* The JSON Schema for API Extractor's *.api.json files (api-json.schema.json).
*/
ApiJsonFile.jsonSchema = node_core_library_1.JsonSchema.fromFile(path.join(__dirname, './api-json.schema.json'));
exports.ApiJsonFile = ApiJsonFile;
//# sourceMappingURL=ApiJsonFile.js.map