Docs are a work in progress - contributions welcome
Logonestjs-openapi
Advanced

Advanced Usage

Advanced patterns and integration options for nestjs-openapi

This section covers advanced use cases, internal APIs, and integration patterns for power users.

Topics

When to Use Advanced APIs

The standard generate() function and CLI cover most use cases:

// Standard usage - sufficient for 90% of cases
import { generate } from 'nestjs-openapi';

await generate('./openapi.config.ts');

Consider advanced APIs when you need:

  • Custom build pipelines - Integrate with existing Effect-TS applications
  • Fine-grained control - Access intermediate results (method infos, schemas)
  • Custom error handling - Use Effect's typed error channels
  • Shared configuration - Inherit settings across multiple configs
  • Understanding internals - Debug or extend the library

Advanced Exports

The library exports additional APIs for advanced use cases:

// Effect-based generation
import {
  generateEffect,
  generateAsync,
  type GenerateOptions,
} from 'nestjs-openapi';

// Domain types for custom processing
import type { MethodInfo, ResolvedConfig, HttpMethod } from 'nestjs-openapi';

// Typed errors for error handling
import {
  ConfigNotFoundError,
  EntryNotFoundError,
  type GeneratorError,
} from 'nestjs-openapi';

// Low-level utilities
import {
  getModules,
  getAllControllers,
  getMethodInfo,
  transformMethods,
} from 'nestjs-openapi';

Comparison: Standard vs Advanced

FeatureStandard APIAdvanced API
Config fileRequiredOptional
Error handlingtry/catchEffect typed errors
OutputFile writtenIn-memory paths
ComplexityLowHigh
Use caseCLI, scriptsCustom tooling

Prerequisites

Advanced usage assumes familiarity with:

  • TypeScript and its type system
  • Effect-TS (for Effect API)
  • ts-morph (for understanding internals)
  • OpenAPI 3.0 specification

If you're new to Effect-TS, start with the Effect documentation.

On this page