Docs are a work in progress - contributions welcome
Logonestjs-openapi
API Reference

Spec Validation

Detect broken $ref references in OpenAPI specs

Validate generated OpenAPI specs for missing $ref targets. The CLI runs this check automatically and prints warnings without failing generation.

validateSpec()

function validateSpec(spec: OpenApiSpec): ValidationResult;

Returns a summary of total refs, broken refs, and missing schema names.

import { generate, formatValidationResult } from 'nestjs-openapi';

const result = await generate('./openapi.config.ts');

if (!result.validation.valid) {
  console.warn(formatValidationResult(result.validation));
}

formatValidationResult()

function formatValidationResult(result: ValidationResult): string;

Formats a readable summary suitable for CLI output. Includes categories for primitive types, union types, query/path params, and other missing schemas.

categorizeBrokenRefs()

function categorizeBrokenRefs(
  missingSchemas: ReadonlyMap<string, number>,
): BrokenRefCategories;

Groups missing schema names to help diagnose where refs are coming from.

See the full type definitions in Types.

On this page