applyDocfyMetadata(document, options?)
Merges the build-time metadata produced by the nestjs-docfy CLI plugin into an already-built OpenAPI document.
Usage
Call this right after SwaggerModule.createDocument(), at the same lifecycle point a manually-run patch-spec output would be merged at, except this runs automatically on every build instead of a separate CLI step. See The CLI plugin for the full picture, including registering it in nest-cli.json.
ts
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { applyDocfyMetadata } from 'nestjs-docfy';
const app = await NestFactory.create(AppModule);
const document = SwaggerModule.createDocument(app, new DocumentBuilder().build());
SwaggerModule.setup('api', app, applyDocfyMetadata(document));
await app.listen(3000);Options
| Option | Type | Default | Description |
|---|---|---|---|
metadataPath | string | docfy-metadata.json next to the entry file | Absolute path to the metadata file the plugin wrote. |
strict | boolean | false | Throw instead of warning when the metadata file is missing or unparseable. Mirrors DocfyModule.forRoot({ strict }). |
Fail-open by default
If the metadata file isn't found (for example, the plugin isn't registered in nest-cli.json), it warns and returns the document unchanged, the same fail-open default as DocfyModule.forRoot().