A helper library for loading and saving the .api.json files created by API Extractor
example.api.json, which would be generated by API Extractor
example:
ts
import { ApiModel, ApiPackage } from '@microsoft/api-extractor-model';
const apiModel: ApiModel = new ApiModel();
const apiPackage: ApiPackage = apiModel.loadPackage('example.api.json');
for (const member of apiPackage.members) {
console.log(member.displayName);
}
`
The ApiModel is acts as a container for various packages that are loaded and operated on as a group.
For example, a documentation tool may need to resolve @link references across different packages.
In this case we would load the various packages into the ApiModel, and then use
the ApiModel.resolveDeclarationReference() to resolve the @link targets.
The data structure forms a tree of various classes that start with the Api prefix. The nesting hierarchy
might look like this:
`
- ApiModel
- ApiPackage
- ApiEntryPoint
- ApiClass
- ApiMethod
- ApiProperty
- ApiEnum
- ApiEnumMember
- ApiInterface
- ApiMethodSignature
- ApiPropertySignature
- ApiNamespace
- (ApiClass, ApiEnum, ApiInterace, ...)
`
You can use the ApiItem.members property to traverse this tree.
Note that the non-abstract classes (e.g. ApiClass, ApiEnum, ApiInterface, etc.) use
TypeScript "mixin" functions (e.g. ApiDeclaredItem, ApiItemContainerMixin`, etc.) to add various