Skip to content
Starlight OpenAPI
GitHub

Getting Started

Features

  • Support for Swagger 2.0, OpenAPI 3.0 and OpenAPI 3.1 specifications.
  • Support for local and remote schemas.
  • Configurable sidebar label and sidebar group collapsing.

Installation

Install the Starlight OpenAPI integration using your favorite package manager:

npm i starlight-openapi

Update your Astro configuration to generate documentation from your OpenAPI/Swagger specification:

import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
import { generateAPI } from 'starlight-openapi'

// Generate the documentation and get the associated sidebar groups.
const { openAPISidebarGroups, starlightOpenAPI } = await generateAPI([
  {
    base: 'api',
    label: 'My API',
    schema: '../schemas/api-schema.yaml',
  },
])

export default defineConfig({
  // …
  integrations: [
    starlight({
      sidebar: [
        {
          label: 'Guides',
          items: [{ label: 'Example Guide', link: '/guides/example/' }],
        },
        // Add the generated sidebar groups to the sidebar.
        ...openAPISidebarGroups,
      ],
      title: 'My Docs',
    }),
    // Add the Starlight OpenAPI integration.
    starlightOpenAPI(),
  ],
})

For more details, please refer to the configuration documentation.