OpenAPI

Generate and document your OpenAPI schema

Introduction

Fumadocs provides an official OpenAPI integration to generate and document your OpenAPI schema.

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

Changing the OpenAPI schema

The generate-docs script uses the OpenAPI schema to generate the documentation. You can change the OpenAPI schema by modifying the openapi.json file in content/docs/api-reference of your project.

scripts/generate-docs.mts
import * as  from 'fumadocs-openapi';
import {  } from 'rimraf';

export async function () {
  await ('./content/docs/api-reference', {
    () {
      return (
        !.('index.mdx') &&
        !.('openapi.json') &&
        !.('openapi.yml') &&
        !.('meta.json')
      );
    },
  });

  await .([
    .({
      : ['./content/docs/api-reference/openapi.yml'],
      : './content/docs/api-reference',
      : 'operation',
      : true,
      : 'tag',
    }),
  ]);
}

Only OpenAPI 3.0 and 3.1 are supported.

Generate docs with the script:

bun run build:pre

Removing the OpenAPI Integration

Last updated on