Rush StackShopBlogEvents
Skip to main content

Home > @microsoft/api-extractor-model > ApiModel

ApiModel class

A serializable representation of a collection of API declarations.

Signature:

export declare class ApiModel extends ApiModel_base 

Extends: ApiModel_base

Remarks

An ApiModel represents a collection of API declarations that can be serialized to disk. It captures all the important information needed to generate documentation, without any reliance on the TypeScript compiler engine.

An ApiModel acts as the root of a tree of objects that all inherit from the ApiItem base class. The tree children are determined by the ApiItemContainerMixin mixin base class. The model contains packages. Packages have an entry point (today, only one). And the entry point can contain various types of API declarations. The container relationships might look like this:

Things that can contain other things:

- ApiModel
- ApiPackage
- ApiEntryPoint
- ApiClass
- ApiMethod
- ApiProperty
- ApiEnum
- ApiEnumMember
- ApiInterface
- ApiMethodSignature
- ApiPropertySignature
- ApiNamespace
- (ApiClass, ApiEnum, ApiInterace, ...)

Normally, API Extractor writes an .api.json file to disk for each project that it builds. Then, a tool like API Documenter can load the various ApiPackage objects into a single ApiModel and process them as a group. This is useful because compilation generally occurs separately (e.g. because projects may reside in different Git repos, or because they build with different TypeScript compiler configurations that may be incompatible), whereas API Documenter cannot detect broken hyperlinks without seeing the entire documentation set.

Constructors

ConstructorModifiersDescription
(constructor)()Constructs a new instance of the ApiModel class

Properties

PropertyModifiersTypeDescription
containerKeyreadonlystring
kindreadonlyApiItemKind
packagesreadonlyReadonlyArray<ApiPackage>

Methods

MethodModifiersDescription
addMember(member)
buildCanonicalReference()(BETA)
loadPackage(apiJsonFilename)
resolveDeclarationReference(declarationReference, contextApiItem)
tryGetPackageByName(packageName)Efficiently finds a package by the NPM package name.