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
Programmatic API
Use nestjs-openapi in build scripts and custom tooling
Effect-TS API
Integrate with Effect-TS for functional error handling
Config Inheritance
Share configuration across multiple applications
Internals
How the library works under the hood
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
| Feature | Standard API | Advanced API |
|---|---|---|
| Config file | Required | Optional |
| Error handling | try/catch | Effect typed errors |
| Output | File written | In-memory paths |
| Complexity | Low | High |
| Use case | CLI, scripts | Custom 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.