payload-plugin-openapi
OpenAPI 3.0/3.1/3.2 spec generator for Payload CMS, with Scalar/Swagger UI.
A Payload CMS plugin that auto-generates OpenAPI 3.0/3.1/3.2 documentation from your CMS config. Adds an interactive API browser at /api/docs with no manual annotation needed.
This is a plugin for Payload CMS that automatically generates API documentation. Payload CMS is a content management system built with TypeScript that developers use to build websites and apps with a structured content backend. This plugin reads your Payload configuration and produces an OpenAPI document, which is a standard format for describing what API endpoints exist, what data they accept, and what they return.
The main benefit is that no manual annotation is required. Rather than writing out each endpoint in a documentation format by hand, the plugin inspects your Payload collections, global settings, authentication routes, content versions, and scheduled jobs, and generates the documentation automatically. You can then browse that documentation through an interactive interface at a URL like /api/docs.
The plugin supports two visual documentation browsers: Scalar and Swagger UI. Both display the endpoints as clickable, interactive pages where you can send test requests directly from the browser. You add one or two lines to your Payload configuration, and the documentation appears immediately. The documentation endpoint itself is at /api/openapi.json by default.
There are several ways to customize it. You can filter which collections and operations appear in the documentation, add descriptions to specific fields, document custom API routes that Payload does not generate automatically, and choose between OpenAPI versions 3.0, 3.1, and 3.2. The plugin also supports caching the generated document in memory so it does not rebuild on every request. For automated workflows, the spec can be written to a file for use in testing pipelines or code generation tools.
Installing the plugin requires Payload version 3.53.0 or newer and Node.js 20 or later. It is available on npm as @seshuk/payload-plugin-openapi.
Where it fits
- Instantly add interactive API docs to a Payload CMS project with two lines of config
- Export an OpenAPI spec file from Payload CMS for use in client SDK generation or CI schema diffs
- Expose a filtered subset of Payload endpoints as a public-facing API reference
- Document custom Payload endpoints alongside auto-generated ones in a single unified spec