Autogenerates an OpenAPI 3.0 or 3.1 specification from a Payload CMS instance, covering collection and global CRUD, auth and preferences endpoints. It is added as a plugin in the Payload config and serves the spec as JSON from an API route. Optional plugins add Scalar, Swagger UI, RapiDoc or Redoc viewers. Requires Payload 3.x.
An OpenAPI plugin for Payload CMS
Installation
npm i payload-oapi125
Stars
25
Forks
13
Open Issues
2 months ago
Last Updated
31.7k
Weekly Downloads
v0.3.1
npm Version
188.8 KB
Unpacked Size
4
Dependencies
125+3 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 125 |
| Dec 4, 2026 | 125 |
| Dec 3, 2026 | 125 |
| Dec 2, 2026 | 125 |
| Dec 1, 2026 | 125 |
| Nov 30, 2026 | 125 |
| Nov 29, 2026 | 125 |
| Nov 28, 2026 | 125 |
| Nov 27, 2026 | 125 |
| Nov 26, 2026 | 125 |
| Nov 25, 2026 | 125 |
| Nov 24, 2026 | 125 |
| Nov 23, 2026 | 125 |
| Nov 22, 2026 | 125 |
| Nov 21, 2026 | 125 |
| Nov 20, 2026 | 125 |
| Nov 19, 2026 | 125 |
| Nov 18, 2026 | 125 |
| Nov 17, 2026 | 125 |
| Nov 16, 2026 | 125 |
| Nov 15, 2026 | 125 |
| Nov 14, 2026 | 125 |
| Nov 13, 2026 | 125 |
| Nov 12, 2026 | 125 |
| Nov 11, 2026 | 125 |
| Nov 10, 2026 | 125 |
| Nov 9, 2026 | 125 |
| Nov 8, 2026 | 125 |
| Nov 7, 2026 | 125 |
| Nov 6, 2026 | 125 |
| Nov 5, 2026 | 125 |
| Nov 4, 2026 | 125 |
| Nov 3, 2026 | 125 |
| Nov 2, 2026 | 125 |
| Nov 1, 2026 | 125 |
| Oct 31, 2026 | 125 |
| Oct 30, 2026 | 125 |
| Oct 29, 2026 | 125 |
| Oct 28, 2026 | 125 |
| Oct 27, 2026 | 125 |
| Oct 26, 2026 | 125 |
| Oct 25, 2026 | 125 |
| Oct 24, 2026 | 125 |
| Oct 23, 2026 | 125 |
| Oct 22, 2026 | 125 |
| Oct 21, 2026 | 125 |
| Oct 20, 2026 | 125 |
| Oct 19, 2026 | 125 |
| Oct 18, 2026 | 125 |
| Oct 17, 2026 | 125 |
| Oct 16, 2026 | 125 |
| Oct 15, 2026 | 125 |
| Oct 14, 2026 | 125 |
| Oct 13, 2026 | 124 |
| Oct 12, 2026 | 124 |
| Oct 11, 2026 | 124 |
| Oct 10, 2026 | 124 |
| Oct 9, 2026 | 124 |
| Oct 8, 2026 | 124 |
| Oct 7, 2026 | 124 |
| Oct 6, 2026 | 124 |
| Oct 5, 2026 | 124 |
| Oct 4, 2026 | 124 |
| Oct 3, 2026 | 124 |
| Oct 2, 2026 | 124 |
| Oct 1, 2026 | 124 |
| Sep 30, 2026 | 124 |
| Sep 29, 2026 | 124 |
| Sep 28, 2026 | 124 |
| Sep 27, 2026 | 124 |
| Sep 26, 2026 | 124 |
| Sep 25, 2026 | 124 |
| Sep 24, 2026 | 124 |
| Sep 23, 2026 | 124 |
| Sep 22, 2026 | 123 |
| Sep 21, 2026 | 123 |
| Sep 20, 2026 | 123 |
| Sep 19, 2026 | 123 |
| Sep 18, 2026 | 123 |
| Sep 17, 2026 | 122 |
| Sep 16, 2026 | 122 |
| Sep 15, 2026 | 122 |
| Sep 14, 2026 | 122 |
| Sep 13, 2026 | 122 |
| Sep 12, 2026 | 122 |
| Sep 11, 2026 | 122 |
| Sep 10, 2026 | 122 |
| Sep 9, 2026 | 122 |
| Sep 8, 2026 | 122 |
| Sep 7, 2026 | 122 |
| Sep 6, 2026 | 122 |
31.3K+20.1K since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 31,264 |
| Dec 4, 2026 | 30,289 |
| Dec 3, 2026 | 29,263 |
| Dec 2, 2026 | 30,715 |
| Dec 1, 2026 | 32,537 |
| Nov 30, 2026 | 31,349 |
| Nov 29, 2026 | 30,304 |
| Nov 28, 2026 | 30,446 |
| Nov 27, 2026 | 30,109 |
| Nov 26, 2026 | 30,270 |
| Nov 25, 2026 | 29,816 |
| Nov 24, 2026 | 28,263 |
| Nov 23, 2026 | 28,784 |
| Nov 22, 2026 | 29,304 |
| Nov 21, 2026 | 30,240 |
| Nov 20, 2026 | 30,792 |
| Nov 19, 2026 | 29,997 |
| Nov 18, 2026 | 28,324 |
| Nov 17, 2026 | 27,292 |
| Nov 16, 2026 | 27,098 |
| Nov 15, 2026 | 25,843 |
| Nov 14, 2026 | 25,189 |
| Nov 13, 2026 | 25,380 |
| Nov 12, 2026 | 25,107 |
| Nov 11, 2026 | 24,325 |
| Nov 10, 2026 | 23,654 |
| Nov 9, 2026 | 22,930 |
| Nov 8, 2026 | 22,795 |
| Nov 7, 2026 | 21,135 |
| Nov 6, 2026 | 20,360 |
| Nov 5, 2026 | 19,706 |
| Nov 4, 2026 | 19,782 |
| Nov 3, 2026 | 20,017 |
| Nov 2, 2026 | 20,865 |
| Nov 1, 2026 | 20,848 |
| Oct 31, 2026 | 21,242 |
| Oct 30, 2026 | 20,307 |
| Oct 29, 2026 | 16,676 |
| Oct 28, 2026 | 13,359 |
| Oct 27, 2026 | 14,276 |
| Oct 26, 2026 | 14,068 |
| Oct 25, 2026 | 14,082 |
| Oct 24, 2026 | 14,567 |
| Oct 23, 2026 | 11,246 |
| Oct 22, 2026 | 14,967 |
| Oct 21, 2026 | 18,120 |
| Oct 20, 2026 | 16,723 |
| Oct 19, 2026 | 15,819 |
| Oct 18, 2026 | 15,188 |
| Oct 17, 2026 | 14,946 |
| Oct 16, 2026 | 18,458 |
| Oct 15, 2026 | 18,616 |
| Oct 14, 2026 | 18,251 |
| Oct 13, 2026 | 18,206 |
| Oct 12, 2026 | 18,262 |
| Oct 11, 2026 | 18,502 |
| Oct 10, 2026 | 17,472 |
| Oct 9, 2026 | 17,049 |
| Oct 8, 2026 | 17,014 |
| Oct 7, 2026 | 17,150 |
| Oct 6, 2026 | 17,048 |
| Oct 5, 2026 | 17,011 |
| Oct 4, 2026 | 16,308 |
| Oct 3, 2026 | 15,653 |
| Oct 2, 2026 | 14,690 |
| Oct 1, 2026 | 12,789 |
| Sep 30, 2026 | 12,992 |
| Sep 29, 2026 | 13,195 |
| Sep 28, 2026 | 13,177 |
| Sep 27, 2026 | 13,657 |
| Sep 26, 2026 | 14,451 |
| Sep 25, 2026 | 15,329 |
| Sep 24, 2026 | 16,799 |
| Sep 23, 2026 | 16,643 |
| Sep 22, 2026 | 16,741 |
| Sep 21, 2026 | 17,317 |
| Sep 20, 2026 | 17,254 |
| Sep 19, 2026 | 16,662 |
| Sep 18, 2026 | 16,396 |
| Sep 17, 2026 | 16,290 |
| Sep 16, 2026 | 14,937 |
| Sep 15, 2026 | 15,228 |
| Sep 14, 2026 | 14,802 |
| Sep 13, 2026 | 14,033 |
| Sep 12, 2026 | 13,736 |
| Sep 11, 2026 | 13,278 |
| Sep 10, 2026 | 12,103 |
| Sep 9, 2026 | 12,480 |
| Sep 8, 2026 | 11,806 |
| Sep 7, 2026 | 11,233 |
| Sep 6, 2026 | 11,146 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/618796772-root)<a href="https://payloaddirectory.dev/plugins/618796772-root"><img src="https://payloaddirectory.dev/badge/618796772-root.svg" alt="Payload Directory"></a>README
Autogenerate an OpenAPI specification from your Payload CMS instance and use it for documentation or to generate client SDKs.
You can install the plugin using your preferred package manager:
pnpm add payload-oapinpm install payload-oapiyarn add payload-oapiTo add the OpenAPI specification endpoint to your Payload app, simply import the openapi plugin and add it to your payload configuration:
import { openapi } from 'payload-oapi'
buildConfig({
plugins: [
openapi({ openapiVersion: '3.0', metadata: { title: 'Dev API', version: '0.0.1' } }),
],
// ...
})
To provide a user interface for your API documentation, you can add one of the following plugins:
Example usage:
import { openapi, scalar, swaggerUI, rapidoc, redoc } from 'payload-oapi'
// Choose one documentation UI plugins as needed
buildConfig({
plugins: [
openapi(/* ... */),
// Uncomment the UI you want to use:
scalar({ /* ...options */ }),
// swaggerUI({ /* ...options */ }),
// rapidoc({ /* ...options */ }),
// redoc({ /* ...options */ }),
],
// ...
})
Control which collections and globals appear in the OpenAPI spec using the filters option:
includeCollections / excludeCollections — filter collections by slugincludeGlobals / excludeGlobals — filter globals by slughideInternalCollections — exclude payload-* collectionsExample:
openapi({
openapiVersion: '3.0',
metadata: { title: 'Dev API', version: '0.0.1' },
filters: {
includeCollections: ['posts', 'categories'],
excludeGlobals: ['footer'],
hideInternalCollections: true,
},
})
Generated operation paths are prefixed with your Payload routes.api setting. Set apiBasePath if clients reach the
API under a different prefix, e.g. behind a reverse proxy:
openapi({
openapiVersion: '3.0',
metadata: { title: 'Dev API', version: '0.0.1' },
apiBasePath: '/public-api',
})
Payload endpoints — on a collection, a global or the config root — are documented when they carry an OpenAPI
operation under custom.openapi. Anything you do not set is filled in for you (tags, operationId, summary, and a
security requirement, since the generator cannot inspect a custom handler's access control):
import type { CustomEndpointDocumentation } from 'payload-oapi'
const Pets: CollectionConfig = {
slug: 'pets',
endpoints: [
{
path: '/by-status/:status',
method: 'get',
handler: myHandler,
custom: {
openapi: {
summary: 'List pets by status',
security: [],
parameters: [{ in: 'path', name: 'status', required: true, schema: { type: 'string' } }],
responses: {
200: {
description: 'Pets with the requested status',
content: {
'application/json': {
schema: { type: 'array', items: { $ref: '#/components/schemas/Pet' } },
},
},
},
},
} satisfies CustomEndpointDocumentation,
},
},
],
// ...
}
Write these in OpenAPI 3.1 syntax whatever openapiVersion you configured — a 3.0 spec is down-converted on the way
out. $ref pointers to generated components work as shown; to add schemas of your own, declare them through Payload's
typescript.schema and reference them the same way.
adjustGeneratedSpec gets the last word on the spec. Use it for anything the plugin does not model —
paths Payload does not serve, extra components, or removing a generated operation that you'd like to exclude from the spec:
openapi({
metadata: { title: 'Dev API', version: '0.0.1' },
adjustGeneratedSpec: (spec, req) => {
spec.paths['/external/health'] = {
get: { summary: 'Health check', responses: { 200: { description: 'ok' } } },
}
delete spec.paths['/api/posts'].post
},
})
openapiVersion: '3.0' — write 3.1 syntax and it
is down-converted afterwards, exactly like custom.openapiasyncreq, so the spec can depend on the locale or the current user$ref targets are already resolved, so generated components can be reused by pointerComponent names derive from labels.singular, so they are not a stable contract — a collection you
declare yourself gets Post, while the same slug can yield Posts elsewhere. Copy a $ref the
generator produced instead of assembling one:
adjustGeneratedSpec: spec => {
const posts = spec.paths['/api/posts'].get.responses['200'] // { $ref: '…/PostListResponse' }
spec.paths['/external/latest'] = { get: { responses: { 200: posts } } }
}
Collections with auth get their login, logout, refresh, verification and password-reset operations documented
automatically, following that collection's auth config — disableLocalStrategy drops the password operations,
loginWithUsername decides whether the login body takes an email or a username, maxLoginAttempts: 0 drops
/unlock, and verify adds /verify/{id}.
Unless you configured it otherwise, your spec will be accessible via https://your-payload.com/api/openapi.json. If you added a documentation UI, that will be accessible via https://your-payload.com/api/docs (this is also configurable).
payload plugin openapi
Generate an OpenAPI 3.0, 3.1 or 3.2 spec from your Payload config and serve it with Scalar or Swagger UI
701.4k/wk18v4
openapi
Generate OpenAPI 3 documents from your Payload config, including collection, global and custom endpoints
521.4k/wk143v1
swagger
Generate OpenAPI 3 docs from your Payload config and serve them through Swagger UI
541.4k/wk143v1
query
Typesafe query filters and field selection for Payload's REST and internal APIs
4526/wk143v1
payload plugin api guide
Generates a live API reference and agent-readable query guide from your Payload configuration
448/wk2v3
payload rest client
Typesafe REST API client for Payload collections, globals, auth and custom endpoints
43956/wk49v?