OpenAPI Generator
Generating docs for OpenAPI schema
Usage
Install the required packages.
Generate Styles
The interactive UI of OpenAPI integration is styled with Tailwind CSS, it doesn't include a pre-built stylesheet by default. You must use it in conjunction with the official Tailwind CSS plugin.
Add the package to content
under your Tailwind CSS configuration.
Generate Files
Create a script:
Only OpenAPI 3.0 is supported.
It doesn't allow JSON schema specific keywords like const
, as they are unsupported
Generate docs with the script:
Fumadocs OpenAPI generates MDX content directly, you can use a formatter (e.g. Prettier) to format the output files.
Generate Page Tree
You can add the attachFile
to decorate the page tree with Source API.
It adds a badge to each page item.
Features
The official OpenAPI integration supports:
- Basic API endpoint information
- Interactive API playground
- Example code to send request (in different programming languages)
- Response samples and TypeScript definitions
- Request parameters and body generated from schemas
Demo
Options
You can also pass options to the generateFiles
function.
Input
An array of input files (path), wildcard allowed.
Output
Path to the output directory.
Per
Customise how the page is generated, default to file
.
mode | Generate a page for |
---|---|
tag | each tag |
file | each schema |
operation | each operation (method of endpoint) |
Group By Folder
In operation
mode, you can group operations with folders.
Name
A function that controls the output path of files.
Imports
The imports on the top of MDX files. When not specified, it imports the required components from the package itself.
Frontmatter
Customise the frontmatter of MDX files.
By default, it includes:
property | description |
---|---|
title | Page title |
description | Page description |
full | Always true, added for Fumadocs UI |
method | Available method of operation (operation mode) |
route | Route of operation (operation mode) |
Generate Code Samples
Generate custom code samples for each API endpoint.
In addition, you can also specify code samples via OpenAPI schema.
Renderer
Customise how components are generated.
Last updated on