Creates an OpenAPI 3.0 document as a JavaScript object from your Payload configuration. It documents collection, global, custom, authentication and preferences endpoints with typed schemas and authentication requirements. Built for Payload 1.x, it is called through a createDocument function and can merge in extra OpenAPI definitions from package.json or a dot-openapi file.
Create openapi documentation for your payload cms
Installation
npm i payload-openapi143
Stars
15
Forks
13
Open Issues
2 years ago
Last Updated
1.4k
Weekly Downloads
v1.4.0
npm Version
109.1 KB
Unpacked Size
3
Dependencies
143+2 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 143 |
| Dec 4, 2026 | 143 |
| Dec 3, 2026 | 143 |
| Dec 2, 2026 | 143 |
| Dec 1, 2026 | 143 |
| Nov 30, 2026 | 143 |
| Nov 29, 2026 | 143 |
| Nov 28, 2026 | 143 |
| Nov 27, 2026 | 143 |
| Nov 26, 2026 | 143 |
| Nov 25, 2026 | 143 |
| Nov 24, 2026 | 143 |
| Nov 23, 2026 | 143 |
| Nov 22, 2026 | 143 |
| Nov 21, 2026 | 143 |
| Nov 20, 2026 | 143 |
| Nov 19, 2026 | 143 |
| Nov 18, 2026 | 143 |
| Nov 17, 2026 | 143 |
| Nov 16, 2026 | 143 |
| Nov 15, 2026 | 143 |
| Nov 14, 2026 | 143 |
| Nov 13, 2026 | 143 |
| Nov 12, 2026 | 143 |
| Nov 11, 2026 | 143 |
| Nov 10, 2026 | 143 |
| Nov 9, 2026 | 143 |
| Nov 8, 2026 | 143 |
| Nov 7, 2026 | 142 |
| Nov 6, 2026 | 142 |
| Nov 5, 2026 | 142 |
| Nov 4, 2026 | 142 |
| Nov 3, 2026 | 142 |
| Nov 2, 2026 | 142 |
| Nov 1, 2026 | 142 |
| Oct 31, 2026 | 142 |
| Oct 30, 2026 | 142 |
| Oct 29, 2026 | 142 |
| Oct 28, 2026 | 142 |
| Oct 27, 2026 | 142 |
| Oct 26, 2026 | 142 |
| Oct 25, 2026 | 142 |
| Oct 24, 2026 | 142 |
| Oct 23, 2026 | 142 |
| Oct 22, 2026 | 142 |
| Oct 21, 2026 | 142 |
| Oct 20, 2026 | 142 |
| Oct 19, 2026 | 142 |
| Oct 18, 2026 | 142 |
| Oct 17, 2026 | 142 |
| Oct 16, 2026 | 142 |
| Oct 15, 2026 | 142 |
| Oct 14, 2026 | 142 |
| Oct 13, 2026 | 142 |
| Oct 12, 2026 | 142 |
| Oct 11, 2026 | 142 |
| Oct 10, 2026 | 142 |
| Oct 9, 2026 | 142 |
| Oct 8, 2026 | 142 |
| Oct 7, 2026 | 142 |
| Oct 6, 2026 | 142 |
| Oct 5, 2026 | 142 |
| Oct 4, 2026 | 142 |
| Oct 3, 2026 | 142 |
| Oct 2, 2026 | 142 |
| Oct 1, 2026 | 142 |
| Sep 30, 2026 | 142 |
| Sep 29, 2026 | 142 |
| Sep 28, 2026 | 142 |
| Sep 27, 2026 | 142 |
| Sep 26, 2026 | 142 |
| Sep 25, 2026 | 142 |
| Sep 24, 2026 | 142 |
| Sep 23, 2026 | 142 |
| Sep 22, 2026 | 142 |
| Sep 21, 2026 | 142 |
| Sep 20, 2026 | 142 |
| Sep 19, 2026 | 142 |
| Sep 18, 2026 | 142 |
| Sep 17, 2026 | 142 |
| Sep 16, 2026 | 141 |
| Sep 15, 2026 | 141 |
| Sep 14, 2026 | 141 |
| Sep 13, 2026 | 141 |
| Sep 12, 2026 | 141 |
| Sep 11, 2026 | 141 |
| Sep 10, 2026 | 141 |
| Sep 9, 2026 | 141 |
| Sep 8, 2026 | 141 |
| Sep 7, 2026 | 141 |
| Sep 6, 2026 | 141 |
Shared by 5 plugins in teunmooij/payload-tools.
1.3K−68 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 1,341 |
| Dec 4, 2026 | 1,124 |
| Dec 3, 2026 | 1,109 |
| Dec 2, 2026 | 1,217 |
| Dec 1, 2026 | 1,217 |
| Nov 30, 2026 | 1,200 |
| Nov 29, 2026 | 1,282 |
| Nov 28, 2026 | 1,306 |
| Nov 27, 2026 | 1,486 |
| Nov 26, 2026 | 1,596 |
| Nov 25, 2026 | 1,512 |
| Nov 24, 2026 | 1,574 |
| Nov 23, 2026 | 1,582 |
| Nov 22, 2026 | 1,418 |
| Nov 21, 2026 | 1,561 |
| Nov 20, 2026 | 1,276 |
| Nov 19, 2026 | 1,040 |
| Nov 18, 2026 | 842 |
| Nov 17, 2026 | 818 |
| Nov 16, 2026 | 860 |
| Nov 15, 2026 | 793 |
| Nov 14, 2026 | 606 |
| Nov 13, 2026 | 618 |
| Nov 12, 2026 | 718 |
| Nov 11, 2026 | 763 |
| Nov 10, 2026 | 749 |
| Nov 9, 2026 | 733 |
| Nov 8, 2026 | 715 |
| Nov 7, 2026 | 662 |
| Nov 6, 2026 | 641 |
| Nov 5, 2026 | 599 |
| Nov 4, 2026 | 623 |
| Nov 3, 2026 | 642 |
| Nov 2, 2026 | 616 |
| Nov 1, 2026 | 669 |
| Oct 31, 2026 | 641 |
| Oct 30, 2026 | 641 |
| Oct 29, 2026 | 484 |
| Oct 28, 2026 | 362 |
| Oct 27, 2026 | 322 |
| Oct 26, 2026 | 493 |
| Oct 25, 2026 | 390 |
| Oct 24, 2026 | 404 |
| Oct 23, 2026 | 313 |
| Oct 22, 2026 | 416 |
| Oct 21, 2026 | 478 |
| Oct 20, 2026 | 486 |
| Oct 19, 2026 | 343 |
| Oct 18, 2026 | 347 |
| Oct 17, 2026 | 349 |
| Oct 16, 2026 | 462 |
| Oct 15, 2026 | 416 |
| Oct 14, 2026 | 458 |
| Oct 13, 2026 | 444 |
| Oct 12, 2026 | 414 |
| Oct 11, 2026 | 411 |
| Oct 10, 2026 | 590 |
| Oct 9, 2026 | 776 |
| Oct 8, 2026 | 1,069 |
| Oct 7, 2026 | 1,151 |
| Oct 6, 2026 | 1,194 |
| Oct 5, 2026 | 1,292 |
| Oct 4, 2026 | 1,661 |
| Oct 3, 2026 | 1,672 |
| Oct 2, 2026 | 1,719 |
| Oct 1, 2026 | 1,573 |
| Sep 30, 2026 | 1,613 |
| Sep 29, 2026 | 1,594 |
| Sep 28, 2026 | 1,511 |
| Sep 27, 2026 | 1,356 |
| Sep 26, 2026 | 1,363 |
| Sep 25, 2026 | 1,346 |
| Sep 24, 2026 | 1,385 |
| Sep 23, 2026 | 1,201 |
| Sep 22, 2026 | 1,208 |
| Sep 21, 2026 | 1,208 |
| Sep 20, 2026 | 1,049 |
| Sep 19, 2026 | 847 |
| Sep 18, 2026 | 574 |
| Sep 17, 2026 | 418 |
| Sep 16, 2026 | 484 |
| Sep 15, 2026 | 485 |
| Sep 14, 2026 | 468 |
| Sep 13, 2026 | 429 |
| Sep 12, 2026 | 428 |
| Sep 11, 2026 | 532 |
| Sep 10, 2026 | 744 |
| Sep 9, 2026 | 851 |
| Sep 8, 2026 | 976 |
| Sep 7, 2026 | 1,157 |
| Sep 6, 2026 | 1,409 |
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/611765581-openapi)<a href="https://payloaddirectory.dev/plugins/611765581-openapi"><img src="https://payloaddirectory.dev/badge/611765581-openapi.svg" alt="Payload Directory"></a>README
Generate openapi 3 documentation for your payload cms.
payload-openapi documents ALL your payload openapi endpoints and includes:
Alternatives:
With yarn:
yarn add payload-openapi
With npm:
npm install payload-openapi
payload-openapi creates openAPI documents, version 3.0, as javascript object. If you need a yaml file, please use a library like yaml to convert it.
import { createDocument } from 'payload-swagger';
import payloadConfig from '...';
const openapiDocument = createDocument(payloadConfig, {
/* see options section */
});
The openapi document generated by payload-openapi includes information from the following external sources:
package.json: payload-openapi uses the information in the fields shown below. In openapi a partial openapi document can be included;{
"name": "my payload cms",
"version": "1.2.3",
"description": "My awesome cms",
"license": "MIT",
"openapi": {}
}
.openapi: optional file with partial openapi document in JSON format.The data from all these source is recursively merged into the final document.
payload-openapi has the following options:
interface Options {
/**
* By default the access functions on all collections in the config are called to determine
* the access level of the operations.
* Provide an array of collection slugs to disable this for the given collections,
* or `true` to disable for all.
*/
disableAccessAnalysis?: boolean | string[];
/**
* Exclude parts of the payload config from document generation
*/
exclude?: {
authPaths?: boolean;
authCollection?: boolean;
passwordRecovery: boolean; // default true, set to `false` to include
preferences?: boolean; // default true, set to `false` to include
custom?: boolean;
};
}
By default the schema name is derived from the global / collection slug. If the collection has a value for label.{singular/plural}.openapi or the global a value for label.openapi, that value is used instead.
import { CollectionConfig } from 'payload/types';
const Media: CollectionConfig = {
slug: 'posts',
labels: {
singular: { openapi: 'post' },
plural: { openapi: 'posts' },
},
// ... Rest of collection config
};
Endpoint descriptions and summaries are generated from the description and label/labels.{singular/plural} fields of your globals and collections. If a multilanguage (Record<string, string>) value is found, the order of priority for picking the language is as follows:
This makes it possible to set a custom description for the docs:
import { CollectionConfig } from 'payload/types';
const Media: CollectionConfig = {
slug: 'media',
admin: {
description: {
docs: 'Description used in openapi docs',
en: 'Description used in the admin panel',
},
},
labels: {
singular: 'Single value used everywhere',
plural: {
docs: 'Plural value used in docs',
en: 'Plural value used in admin panel',
},
},
// ... Rest of collection config
};
Custom endpoints on all levels can be fully documented, either by using the defineEndpoint helper:
import { CollectionConfig } from 'payload/types';
import { defineEndpoint } from 'payload-openapi';
const Post: CollectionConfig = {
slug: 'posts',
endpoints: [
defineEndpoint({
summary: 'media by category',
description: 'gets the media of the given category',
path: '/category/:category',
method: 'get',
responseSchema: 'posts',
errorResponseSchemas: {
404: 'error',
},
queryParameters: {
limit: { schema: { type: 'number' } },
page: { schema: { type: 'number' } },
sort: { scema: { type: 'string' } },
},
handler: (req, res) => {
// ... handler implementation
},
}),
],
// ... Rest of collection config
};
or by setting the custom.openapi property:
import { CollectionConfig } from 'payload/types';
import type { EndpointDocumentation } from 'payload-openapi';
const documentation: EndpointDocumentation = {
summary: 'media by category',
description: 'gets the media of the given category',
responseSchema: 'posts',
errorResponseSchemas: {
404: { type: 'object', properties: { message: { type: 'string' } }, required: ['message'] },
},
queryParameters: {
limit: { schema: { type: 'number' } },
page: { schema: { type: 'number' } },
sort: { scema: { type: 'string' } },
},
};
const Post: CollectionConfig = {
slug: 'posts',
endpoints: [
{
path: '/category/:category',
method: 'get',
handler: (req, res) => {
// ... handler implementation
},
custom: {
openapi: documentation,
},
},
],
// ... Rest of collection config
};
Response schemas can be defined as openapi schema objects or as string, referencing any of the schemas defined in the schema section of the openapi document.
To exclude a custom endpoint from the documentation, set the custom.openapi property to false.
Examples can be added on collections and globals using the defineCollection or defineGlobal helper:
import { defineCollection } from 'payload-openapi';
const Categories = defineCollection({
slug: 'categories',
example: {
name: 'Example Category',
archived: false,
},
// ... Rest of collection config
});
Or by setting the custom.openapi property:
import { CollectionConfig } from 'payload/types';
const Categories: CollectionConfig = {
slug: 'categories',
custom: {
openapi: {
example: {
name: 'Example Category',
archived: false,
},
},
},
// ... Rest of collection config
};
It's also possible to set multiple examples:
import { defineCollection } from 'payload-openapi';
const Categories = defineCollection({
slug: 'categories',
examples: {
active: {
value: {
name: 'Active Category',
archived: false,
},
summary: 'Example of an active category',
},
archive: {
value: {
name: 'Archived Category',
archived: true,
},
summary: 'Example of an archived category',
},
},
// ... Rest of collection config
});
Openapi supports examples at lots of different levels. To add examples add other levels, you can define theme in a separate partial openapi document, as described here.
In Payload collections and globals have a standard set of available endpoints. In some situations you might not want to use some of these endpoints. In those situations you probably have used an access method that looks something like this: () => false;. This blocks all traffic, but the endpoint is still part of the openapi documentation.
To also remove the endpoint from the openapi documentation, you can use payload-rbac:
import { CollectionConfig } from 'payload/types';
import { blockAll } from 'payload-rbac';
const Media: CollectionConfig: {
slug: 'media',
access: {
delete: blockAll(), // Use block all to exclude endpoint from docs
},
// ... Rest of collection config
}
See changelog
payload oapi
Generate an OpenAPI spec from your Payload config with optional documentation UIs
7631.1k/wk125v3
swagger
Generate OpenAPI 3 docs from your Payload config and serve them through Swagger UI
541.4k/wk143v1
create api docs
CLI that generates OpenAPI 3 documentation for a Payload CMS project
4348/wk143v1
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
payload schema export
Serve a JSON description of your Payload collections, fields, relations, locales and REST routes
6010/wk0v3
query
Typesafe query filters and field selection for Payload's REST and internal APIs
4526/wk143v1