@nestjs/swagger

The official NestJS module that generates OpenAPI (Swagger) documentation from your controllers and DTOs

Library
npm
v12.0.2
1,893 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 96
Maintenance 96
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 80
Code Quality 84
Innovation 68
Learning Curve 75

@nestjs/swagger is the official NestJS module for generating OpenAPI 3 specifications directly from your existing controllers, DTOs, and decorators, rather than requiring a hand-maintained YAML/JSON spec. It scans your application’s routes and TypeScript types at bootstrap and produces both a machine-readable OpenAPI document and an interactive Swagger UI page, using decorators like @ApiProperty() and @ApiOperation() to enrich the generated schema with descriptions, examples, and validation constraints.

A companion CLI plugin can additionally read your TypeScript AST at build time to infer property types and add many @ApiProperty() annotations automatically, cutting down the amount of decorator boilerplate needed to keep documentation in sync with code.

What You Get

  • DocumentBuilder - a fluent builder for describing API-level metadata (title, description, version, servers, security schemes)
  • SwaggerModule.setup() - serves an interactive Swagger UI page and the raw OpenAPI JSON/YAML from your running Nest app
  • @ApiProperty(), @ApiOperation(), @ApiResponse() and related decorators for enriching generated schemas with descriptions, examples, and types
  • A CLI/webpack plugin that statically analyzes your TypeScript to auto-generate @ApiProperty() decorators, reducing manual annotation
  • Support for OpenAPI security schemes (bearer, API key, OAuth2, cookie) mapped onto Nest guards

Common Use Cases

  • Publishing always-in-sync interactive API documentation for a NestJS REST API without hand-writing an OpenAPI spec
  • Generating a typed OpenAPI contract that frontend teams or codegen tools (openapi-generator, orval) consume to produce API clients
  • Documenting authentication requirements (JWT bearer, API key) alongside endpoint definitions for API consumers
  • Enforcing consistent request/response DTO shapes across a large NestJS codebase via shared @ApiProperty() decorators

Under The Hood

Architecture The library (~11,500 lines) centers on swagger-scanner.ts, swagger-explorer.ts, and swagger-transformer.ts in lib/, which walk a Nest application’s compiled module graph at bootstrap to discover controllers, routes, and DTO metadata, then transform that into an OpenAPI 3 document object; swagger-module.ts exposes the public SwaggerModule.createDocument()/.setup() entry points, and swagger-ui/ bundles and serves the interactive documentation page. A separate plugin/ directory implements a TypeScript AST-analysis plugin that runs at build time (via nest-cli.json or webpack) rather than at request time. Tech Stack Built in TypeScript against @nestjs/common/@nestjs/core as peer dependencies, bundling swagger-ui-dist for the documentation UI and using the OpenAPI 3 specification as its output format; the CLI plugin uses the TypeScript compiler API directly for static type inference. Code Quality test/ mirrors the lib/ structure module-for-module (separate decorators, explorer, plugin, swagger-ui, type-helpers, and utils test directories) plus a distinct e2e/ suite run via its own Vitest config — a clear separation between fast unit tests and slower end-to-end scans of real Nest applications. API Design The decorator surface (@ApiProperty, @ApiOperation, @ApiResponse, etc.) follows NestJS’s existing decorator conventions closely, and DocumentBuilder’s fluent chaining mirrors patterns already familiar from other builder-style NestJS APIs, keeping the learning curve low for anyone already using the framework — the main complexity is knowing which OpenAPI concepts (schemas, security schemes) map to which decorator.

Used by 16 apps in this directory

TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 5 days ago
TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,260

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
78
Repo Health
76
Technical
65
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,378

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
67
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 months ago
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,084

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers