How to use the @microsoft/api-extractor.ApiJsonGenerator.jsonSchema function in @microsoft/api-extractor

To help you get started, we’ve selected a few @microsoft/api-extractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / rushstack / libraries / api-documenter / src / ApiJsonFile.ts View on Github external
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);
  }