Skip to main content

Redoc

You can display the whole OpenAPI documentation using a React component

File format

You cannot import a React component inside a .md file.
Change your file extension to .mdx before importing the React Component.
Read more here about MDX in Docusaurus.

Import

import Redoc from '@theme/Redoc';

Props

NameTypeDescription
specOpenAPI specA JSON content spec to use
urlStringExternal URL to load spec file from

Examples

External URL example

import Redoc from '@theme/Redoc';

<Redoc url="https://redocly.github.io/redoc/openapi.yaml"/>
Loading ...

Webpack loader example

You can provide a JSON spec to the component like this. Webpack will load the file directly, you don't need to use redocusaurus configuration inside docusaurus.config.js.

import Redoc from '@theme/Redoc';
import openApi from './api-with-examples.json'

<Redoc spec={openApi} />
YAML support

You cannot load yaml file like this:

import openApi from './api-with-examples.yaml'

Without the right webpack configuration to handle such file format.