@nestjs/swagger

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

Library
npm
v11.4.7
1,886stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
93/100Excellent
Development Activity96
Maintenance96
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture80
Code Quality84
Innovation68
Learning Curve75

@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
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

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
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

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

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

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
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

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

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

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

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,186

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

View details
79
Repo Health
76
Technical
70
Dependency
Built with
TypeScript98%
Updated yesterday
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,367

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
69
Repo Health
78
Technical
66
Dependency
Built with
TypeScript71%
Go16%
Updated yesterday
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

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
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
98%
Other

Novu

Developer Tools

39,615

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
65
Dependency
Built with
TypeScript98%
Updated today

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

Search