Introducing "Redocusaurus": Redoc for Docusaurus
Redocusaurus
What is it?
It is a preset that allows you to easily integrate OpenAPI documentation into your docs site made with docusaurus. It has 2 main components:
Using Redoc as a React component, this provides 2 theme components, @theme/ApiDoc
and @theme/Redoc
. You can use them directly in js pages in Docusaurus.
This creates routes from your OpenAPI files or URLs and renders with the components provided by the theme.
How to set it up?
Install the preset
npm i --save redocusaurus
Add it to your docusaurus.config.js
:
module.exports = {
// ...
presets: [
// ... Other preset configs
[
'redocusaurus',
{
specs: [{
route: '/api/',
spec: 'https://redocly.github.io/redoc/openapi.yaml',
}],
}
],
],
// ...
};
- Rebuild your site and you will have your OpenAPI docs available at the
/api/
route.
Extra features over directly using Redoc
The theme includes redoc settings and some custom css to make it match the @docusaurus/classic
theme. Along with support for Dark Mode and Server Side Rendering.
Docs
Find the docs and examples at the website : https://redocusaurus.vercel.app/
Github Repo
Find the source and know more on Github.
Top comments (4)
Feel free to open an issue on Github if you are having issues. I have fixed a lot of issues with the builds in the last few releases.
I happen to help a developer set up this integration of existing Swagger API documentation with Docusaurus.
After following the instructions on the ReadMe to the T, seems like he is facing this issue that Andrew pointed out. No amount of downgrade worked.
What should he be doing?
Does this still work? Just tried installing it. nothing happens. no routes on /api available.
Works well on my end, especially with the last few releases. Make sure all dependencies are updated.
One method of troubleshooting that worked well for me was to pull down redocusaurusβ source, and try running the project nested in the βexampleβ folder. If the example works then you could work backwards to find differences in your project.