Skip to content

api

2 posts with the tag “api”

Auto-generated API Docs with Starlight TypeDoc

If you maintain a TypeScript project, keeping API documentation in sync with code is challenging. starlight-typedoc seamlessly integrates TypeDoc generated documentation into your Starlight sidebar.

  • Automation: Generates markdown notes from your TypeScript source.
  • Integration: Pages appear natively in your Starlight structure.
  • Type Safety: Documentation that accurately reflects your types.

It requires typedoc and the plugin:

Terminal window
npm install typedoc starlight-typedoc
import starlightTypeDoc from 'starlight-typedoc';
// ...
plugins: [
starlightTypeDoc({
entryPoints: ['./src/index.ts'],
tsconfig: './tsconfig.json',
}),
],

This will automatically create a new section in your documentation for your API reference!

Showcasing APIs with Starlight OpenAPI

For REST APIs, an OpenAPI (Swagger) specification is the gold standard. starlight-openapi allows you to render these specifications directly within your Starlight documentation site.

  • Schema Rendering: Beautifully formatted API endpoints and models.
  • Sidebar Integration: Adds API categories to your navigation.
  • Multiple Schemas: Support for documenting multiple APIs.
  1. Have your openapi.json or openapi.yaml ready.
  2. Install the plugin:
Terminal window
npm install starlight-openapi
  1. Configure it:
import starlightOpenAPI from 'starlight-openapi';
// ...
plugins: [
starlightOpenAPI([
{
base: 'api',
label: 'My API',
schema: './src/openapi.yaml',
},
]),
],

Your API documentation will now be accessible under /api!