Skip to main content
Version: 2.0.2

Installation

  1. Setup docusaurus project

  2. Install redocusaurus:

    npm

    yarn add redocusaurus
    # OR
    pnpm add redocusaurus
    # OR
    npm i --save redocusaurus
  3. Add it as a preset to your docusaurus config along with @docusaurus/preset-classic and pass options:

    // docusaurus.config.ts
    import type { Config } from '@docusaurus/types';
    import type * as Preset from '@docusaurus/preset-classic';
    import type * as Redocusaurus from 'redocusaurus';

    const config: Config = {
    // ...
    presets: [
    // .. Your other presets' config
    [
    '@docusaurus/preset-classic',
    {
    googleAnalytics: {
    trackingID: 'XXXXXX',
    },
    } satisfies Preset.Options,
    ]
    // Redocusaurus config
    [
    'redocusaurus',
    {
    // Plugin Options for loading OpenAPI files
    specs: [
    // Pass it a path to a local OpenAPI YAML file
    {
    // Redocusaurus will automatically bundle your spec into a single file during the build
    spec: 'openapi/index.yaml',
    route: '/api/',
    },
    // You can also pass it a OpenAPI spec URL
    {
    spec: 'https://redocly.github.io/redoc/openapi.yaml',
    route: '/openapi/',
    },
    ],
    // Theme Options for modifying how redoc renders them
    theme: {
    // Change with your site colors
    primaryColor: '#1890ff',
    },
    },
    ] satisfies Redocusaurus.PresetEntry,
    ],
    // ... Rest of your config
    };

    export default config;

The API Doc will be available at the path specific by route. To skip adding a route altogether just don't set the route property. You will still be able to reference schema elements manually using Schema Imports or create Custom React Pages using the data and theme components. If you have a redocly.yaml it will be loaded automatically.

Options

specs

An array of plugin options, see plugin options for individual option details.

theme

Pass options to customize the theme, see theme options for individual option details.

config (optional)

type: string

Redocly config to bundle file and provide options to. You can provide a custom path to a redocly.yaml file, if not provided then it will try to load it from the root of your project if it exists.

Example: redocly.yaml Reference: https://redocly.com/docs/cli/configuration/. Only supports options marked as "Supported in Redoc CE".

important

When setting the redocly.yaml config, you website renders correctly only once it is built and run with the following commands:

npm run build
npm run serve

When running the website locally, with npm start, some error messages can be displayed.