Skip to main content

Plugins Overview

Apinni’s plugin system allows developers to extend its type generation capabilities by defining custom logic for processing decorators, metadata, and type generation. Plugins integrate with the Apinni pipeline, leveraging lifecycle hooks to customize behavior, and support dependencies for modular and reusable functionality.

Key Features
  • Extend Apinni with custom decorators, metadata, and type generation logic.
  • Support for shareable plugins that can be reused as dependencies.
  • Lifecycle hooks for initializing, processing, and generating types.
  • Dependency management with context sharing for modular plugins.

Plugin Architecture

A Apinni plugin is defined by the ApinniPlugin interface, which specifies a unique name, optional config, lifecycle hooks, and optional dependencies. Plugins can be shareable (usable as dependencies by other plugins) and can manipulate the global context (class and method metadata) or share custom context data with dependent plugins.

Plugin Lifecycle Hooks

Plugins execute the following hooks in order during the Apinni pipeline:

HookDescription
onInitializeRegisters custom decorators in the Apinni registry.
onAfterDecoratorsProcessedRuns after all decorators are processed for validation or preparation.
onProvideSharedContextShares plugin-specific context data with dependent plugins (shareable only).
onConsumeDependencyContextsConsumes shared contexts from dependencies (for plugins with dependencies).
onRegisterMetadataRegisters custom metadata in the generation context.
onGenerateTypesGenerates final type definitions or performs custom generation tasks.
tip

Use onInitialize to register custom decorators and onRegisterMetadata to add plugin-specific metadata, ensuring seamless integration with Apinni’s type generation.

Why Use Plugins?

  • Customization: Add support for new decorators or output formats.
  • Integration: Connect with tools like Swagger for API docs.
  • Modularity: Build reusable components for complex projects.

For building your own, see Creating Plugins.

info

Explore built-in plugins in the Built-in Plugins section.