Skip to content
Starlight OpenAPI
GitHub

Configuration

To generate the documentation from your OpenAPI/Swagger specification, you need to configure the Starlight OpenAPI integration in your Astro configuration.

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

Options

The generateAPI function returns groups of SidebarItem containing the generated documentation sidebar navigation items and an Astro integration that should both be used in your configuration as seen in the getting started guide.

The function accepts an array of objects with the following properties:

NameDescriptionRequired
baseThe base path containing the generated documentation, e.g. 'api/petstore'.
schemaThe OpenAPI/Swagger schema path or URL.
labelThe generated documentation sidebar group label.
collapsedWheter the generated documentation sidebar group should be collapsed by default.

Multiple schemas

You can generate documentation for multiple OpenAPI/Swagger schemas by passing multiple objects to the generateAPI function.

// Generate the documentation for multiple schemas.
const { openAPISidebarGroups, starlightOpenAPI } = await generateAPI([
  {
    base: 'api/petstore',
    label: 'My API',
    schema: '../schemas/api-schema.yaml',
  },
  {
    base: 'api/1password',
    label: '1Password Connect',
    schema: 'https://api.apis.guru/v2/specs/1password.local/connect/1.5.7/openapi.yaml',
  },
])