An OpenAPI plugin for Payload CMS

Autogenerate an OpenAPI specification from your Payload CMS instance and use it for documentation or to generate client SDKs.
- [x] Complete description of collection CRUD endpoints
- [x] Complete description of globals CRUD endpoints
- [x] Integrated Swagger UI and Rapidoc
- [x] Authentication endpoints and specification
- [x] Preferences endpoints
- [x] Support Payload CMS 3.x
- [x] Support generating both OpenAPI 3.0 and 3.1
- [ ] Custom endpoints
You can install the plugin using your preferred package manager:
- pnpm add payload-oapi
- npm install payload-oapi
- yarn add payload-oapi
To add the OpenAPI specification endpoint to your Payload app, simply import the openapi plugin and add it to your payload configuration:
``typescript
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:
- scalar
- swaggerUI
- rapidoc
- redoc
Example usage:
`typescript
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 / }),
],
// ...
})
``
Unless you configured it otherwise, your spec will be accessible via
added a documentation UI, that will be accessible via