Payload Oapi screenshot

Payload Oapi

Author Avatar Theme by Janbuchar
Updated: 27 Sep 2025
109 Stars

A Payload CMS plugin for OpenAPI (3.0, 3.1) specification generation

Categories

Overview

The Payload OpenAPI Plugin is designed to autogenerate an OpenAPI specification from your Payload CMS instance. This specification can be used for documentation purposes or to generate client SDKs. It offers several features and can be easily installed and set up.

Features

  • Autogenerate an OpenAPI specification from your Payload CMS instance
  • Use the specification for documentation or to generate client SDKs
  • Complete description of collection CRUD endpoints
  • Complete description of globals CRUD endpoints
  • Integration with Swagger UI and Rapidoc
  • Planned features include custom endpoints, authentication endpoints and specification, and preferences endpoints

Installation

To install the Payload OpenAPI Plugin, you can use either npm or yarn. Run the following command in your terminal:

yarn add payload-oapi

or

npm i payload-oapi

Setup

To add the OpenAPI specification endpoint to your Payload app, you need to import the openapi plugin and add it to your payload configuration. Here is an example:

import payloadOpenAPIPlugin from 'payload-oapi';

const payloadConfig = {
  // Your existing Payload configuration
  // ...

  plugins: [
    // Your existing plugins
    // ...
  
    payloadOpenAPIPlugin(),
  ],
};

// Continue with your Payload app setup
// ...

To add a documentation UI, you can use various plugins such as Swagger UI, Rapidoc, or Redoc. Here are examples for using Swagger UI and Rapidoc plugins:

import swaggerUI from 'swagger-ui';
import payloadOpenAPIPlugin from 'payload-oapi';

// Import the generated OpenAPI specification
import openAPISpec from './openapi-spec.json';

// Initialize the Swagger UI
swaggerUI({
  spec: openAPISpec
});
import Rapidoc from 'rapidoc';
import payloadOpenAPIPlugin from 'payload-oapi';

// Import the generated OpenAPI specification
import openAPISpec from './openapi-spec.json';

// Generate documentation using Rapidoc
Rapidoc.create({
  specFile: openAPISpec
});

Summary

The Payload OpenAPI Plugin is a useful tool for autogenerating an OpenAPI specification from your Payload CMS instance. It provides various features, such as complete descriptions of CRUD endpoints and integration with popular documentation UI libraries like Swagger UI and Rapidoc. Installation and setup are straightforward, allowing you to easily incorporate the plugin into your Payload app.