@fastify/swagger

Generates and serves OpenAPI/Swagger documentation directly from your Fastify route schemas

Library
npm
v9.8.1
1,092stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
78/100Good
Development Activity72
Maintenance76
Community76
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture78
Code Quality84
Innovation70
Learning Curve80

@fastify/swagger is the official Fastify plugin that generates an OpenAPI (Swagger) specification from the route schemas already defined on your Fastify server, then exposes it as JSON/YAML — no separate annotation layer needed. It is the actively maintained, scoped successor to the original fastify-swagger npm package, which is deprecated in favor of this @fastify/*-namespaced release.

It supports both Swagger 2.0 and OpenAPI 3.x specs, works with any of Fastify’s supported schema validators (JSON Schema, TypeBox, Zod via fastify-type-provider-zod), and is typically paired with @fastify/swagger-ui to render an interactive documentation page.

What You Get

  • Automatic OpenAPI 3.x / Swagger 2.0 spec generation from existing Fastify route schemas
  • A /documentation/json and /documentation/yaml endpoint (configurable) exposing the generated spec
  • Support for $ref resolution, shared schemas, and Fastify’s schema composition features in the generated spec
  • Hooks for enriching generated operations with summary, description, tags, security, and other OpenAPI metadata
  • Compatibility with TypeBox and Zod-based schema definitions via Fastify’s type-provider ecosystem
  • Pairing with @fastify/swagger-ui to serve an interactive Swagger UI page from the same spec

Common Use Cases

  • Publishing always-up-to-date API documentation for a Fastify service without maintaining a separate OpenAPI file by hand
  • Generating a machine-readable OpenAPI spec that downstream tools (client generators, API gateways, contract tests) consume
  • Serving an interactive Swagger UI so frontend or partner teams can explore and try out API endpoints
  • Enforcing schema-first API design where the same JSON Schema drives both runtime validation and public documentation

Under The Hood

Architecture - The plugin hooks into Fastify’s route registration lifecycle: lib/spec/ builds the base OpenAPI/Swagger document object, lib/mode/ handles the two generation strategies (“dynamic”, generating the spec on first request, versus “static”, loading a pre-built spec), and lib/util/ resolves shared $ref schemas and normalizes route-level schema metadata into spec operations, all exposed through the small index.js entrypoint that registers the plugin’s decorators and routes. Tech Stack - Plain CommonJS JavaScript with type: commonjs in package.json, built on Fastify’s plugin encapsulation model (fastify-plugin), tested with Node’s built-in test runner plus c8 for 100%-enforced coverage and tstyche for TypeScript type-definition tests. Code Quality - The codebase enforces full test coverage (c8 --100) across unit and TypeScript typing tests, includes test-types/ for validating the published .d.ts types against real usage, and an examples/ directory demonstrating common integration patterns; the repo has 746 commits since 2017 with continuous recent activity and 100+ tagged releases. API Design - Because the plugin derives documentation entirely from schemas you already define for request/response validation, there is no second source of truth to keep in sync — registering the plugin and optionally attaching @fastify/swagger-ui is typically the entire integration surface, which keeps the API very low-friction for teams already using Fastify’s schema validation.

Used by 9 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
92%
MIT

Dittofeed

Marketing · Automation

2,903

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
63
Dependency
Built with
TypeScript92%
Updated 4 months ago
TypeScript
97%
Other

Infisical

Security · Devops

28,838

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
66
Dependency
Built with
TypeScript97%
Updated today
TypeScript
98%
MIT

Kimi Code CLI

AI Code Assistants · AI Agents · Developer Tools

6,908

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
81
Repo Health
87
Technical
66
Dependency
Built with
TypeScript98%
Updated today
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

27,294

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
88
Repo Health
73
Technical
66
Dependency
Built with
TypeScript99%
Updated today
TypeScript
87%
AGPL 3.0

OpenPanel

Analytics

6,698

Open-source Mixpanel alternative with session replay, MCP integration, and privacy-first product analytics you fully control.

View details
75
Repo Health
74
Technical
69
Dependency
Built with
TypeScript87%
MDX11%
Updated today
TypeScript
99%
MIT

optio

AI Agents · AI Code Assistants

1,034

Self-hosted AI agent workflow orchestration that runs on your Kubernetes cluster — from ticket intake to squash-merged PR, entirely within your infrastructure.

View details
77
Repo Health
81
Technical
70
Dependency
Built with
TypeScript99%
Updated 1 weeks ago
TypeScript
82%
Apache 2.0

Palmr.

File Storage · Security

2,403

Self-hosted, privacy-focused file sharing without limits

View details
45
Repo Health
62
Technical
73
Dependency
Built with
TypeScript82%
MDX13%
Updated 5 months ago
TypeScript
60%
MIT

Scalar

Developer Tools

15,944

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
66
Dependency
Built with
TypeScript60%
Vue35%
Updated yesterday

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