openapi(...) call — combine pieces as needed for your project.
Basic setup
Minimal
The smallest working config:metadata.title and metadata.version are required, everything else has a default.
payload.config.ts
Scalar and Swagger UI side by side
Each renderer is its own plugin — mount both on different paths against the same spec endpoint.payload.config.ts
Shaping the spec
Public API only
Document only thepublic-* collections, and drop one of them by exact slug. include is an allowlist: once it’s non-empty, only matching entities survive.
payload.config.ts
{ kind, slug }).
Read-only spec
Keep every entity but drop all write operations withexcludeOperations.
payload.config.ts
{ slug: 'posts', method: 'get' } style entries to target one entity, or { path: /\/preview$/ } to match by route path.
Auth and security
Interactive auth for a private docs site
Add a token endpoint and a matching security scheme, so the docs UI shows an Authorize dialog where users log in with their Payload credentials instead of pasting a token.payload.config.ts
Security overrides with securityWhen
The plugin marks each operation public or secured by probing your access functions. securityWhen runs last and overrides the detected marking: return true for public, false for secured, undefined to keep the detection.
payload.config.ts
Environments
Development
Turn the cache off so config edits show up without a restart, and surface hidden and Payload-internal collections while debugging.payload.config.ts
Generate only, for CI
No runtime endpoint at all — the plugin registers just theopenapi:generate CLI, and the file is generated at build time.
payload.config.ts
Multi-language docs site
One runtime endpoint, resolved per request via?lang=; Scalar gets a language switcher through sources. Swagger UI has no switcher — mount one instance per language instead.
payload.config.ts
Extensions
Add a webhook path and an API-key security scheme the generator can’t know about, plus a post-build transform.payload.config.ts