@fastify/swagger

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

Library
npm
v9.9.2
1,099 stars
MIT License

Repository Health

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

Technical Analysis

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

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

Activepieces

AI Assistants · Automation · Mcp

25,195

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
64
Dependency
Built with
TypeScript 100%
Updated yesterday
TypeScript
91%
MIT

Dittofeed

Automation · Marketing

3,022

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

View details
72
Repo Health
75
Technical
62
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
TypeScript
96%
Other

Infisical

Devops · Security

29,961

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
64
Dependency
Built with
TypeScript 96%
Updated today
TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,983

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
83
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated yesterday
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

29,041

"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
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated today
TypeScript
91%
AGPL 3.0

OpenPanel

Analytics

7,187

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

View details
83
Repo Health
74
Technical
64
Dependency
Built with
TypeScript 91%
Updated yesterday
TypeScript
60%
MIT

optio

AI Agents · AI Code Assistants

1,073

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
82
Repo Health
81
Technical
70
Dependency
Built with
TypeScript 60%
Kotlin 27%
Swift 11%
Updated yesterday
TypeScript
82%
Apache 2.0

Palmr.

File Storage · Security

2,395

Self-hosted, privacy-focused file sharing without limits

View details
57
Repo Health
62
Technical
68
Dependency
Built with
TypeScript 82%
MDX 13%
Updated 1 weeks ago
TypeScript
67%
MIT

Scalar

Developer Tools

16,313

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
65
Dependency
Built with
TypeScript 67%
Vue 29%
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