Skip to content

Components

All components are globally registered by enhanceAppWithOpenApi() — use them directly in any markdown file. See Composing endpoints for usage patterns.

<OpenApiEndpoint>

Renders one operation inline with prose.

md
<OpenApiEndpoint id="public.users.list" />

Props

PropTypeDefaultDescription
idstring(required){specName}.{operationId} for multi-spec, or bare {operationId} with one spec.
auth'none' | 'bearer' | 'apikey' | 'basic' | 'oauth2'auto from specOverride the auth scheme.
serverstringfirst from specSingle-server URL override.
showSection[]all sectionsWhich sections to render.
apiKeyHeaderNamestringauto from specHeader name for apikey schemes.
bodyInputsbooleanfalseRender request body properties as individual inputs instead of a JSON textarea.
layout'columns' | 'stacked''columns'columns renders the Try-It panel as a sticky aside next to the card. stacked keeps everything in one vertical card.

Section names: summary, description, params, request, response, auth, snippets, try.

Layout note: In columns (default) the aside lives inside the endpoint container. On pages where VitePress renders a right-side TOC (aside frontmatter is not false), the aside stacks below the card instead — set aside: false in the page's frontmatter so the endpoint aside has room. Viewports at 1279px and below automatically fall back to the stacked layout regardless of the layout setting.

Stacked layout collapsing: In stacked, Parameters, Authentication, and Code examples are wrapped in <details> collapsed by default. The Try-It panel stays open as the primary call to action.

Parameters table: Operations with more than 3 parameters collapse to 3 rows with a Show all N parameters toggle. The Try-It panel caps at 3 fields before collapsing.

Events

EventPayloadDescription
request-startRequestStartPayloadFires when the Try-It panel sends a request.
request-successRequestSuccessPayloadFires on a successful response.
request-errorRequestErrorPayloadFires on a network or server error.

<OpenApiSpec>

Renders every operation in a spec, grouped by tag.

md
<OpenApiSpec name="public" />
PropTypeDefaultDescription
namestringSpec name from your config.
show-headerbooleantrueRender the spec title and description block.
layout'columns' | 'stacked'inheritCard layout forwarded to every rendered endpoint. Defaults to the plugin defaults.layout.

<OpenApiSchema>

Property table for a named component schema.

md
<OpenApiSchema name="User" spec-name="public" />
PropTypeDescription
namestringSchema name (e.g. User).
spec-namestringWhich spec the schema belongs to.

Renders required badges and turns $ref references into clickable links to other schema pages.

<OpenApiChangelog>

Git-history-driven spec diff.

md
<OpenApiChangelog name="public" />
PropTypeDescription
namestringSpec name.

Shows added/removed/renamed operations and info.* field changes per commit. Delta summary text from the commit message renders with inline markdown (code, bold, italic, links) and is sanitised before mount. Empty state when fewer than two commits touch the spec.

CI note

The changelog needs real git history. Add fetch-depth: 0 to your CI checkout step.

<AuthControls>

Auth input for a single spec. Normally rendered by <OpenApiEndpoint> — use standalone when building custom layouts.

md
<AuthControls spec-name="public" scheme="bearer" />
PropTypeDescription
spec-namestringSpec name.
schemeAuthScheme | 'none'Auth type.
header-namestringHeader name for apikey.
api-key-in'header' | 'query' | 'cookie'Where the API key is sent. Defaults to 'header'.
oauth2-flowParsedOAuth2FlowOAuth2 flow details (authorization URL, token URL, scopes).

<SdkSnippets>

Tabbed code panel for curl / fetch / Python snippets. Tokens come from vue-api-playground 2.5 and render in the shared VS Code Default palette. Normally rendered by <OpenApiEndpoint>.

PropTypeDescription
snippetsSnippet[]Array of { language, label, code, tokens } objects from buildSnippets().
ariaLabelstringAccessible label for the tab list.

<ResponseExamples>

Accordion of status-code rows with syntax-highlighted JSON response bodies. Rows expand lazily via the native <details> element; any number can be open at once. Normally rendered by <OpenApiEndpoint>.

PropTypeDescription
responsesParsedResponse[]Parsed responses from an operation.

<SearchTrigger>

Button that opens the <OperationJumper> dialog.

md
<SearchTrigger text="Search API..." />
PropTypeDefaultDescription
textstring'Search...'Button label.
ariaLabelstring'Search operations and schemas'Accessible label.

<OperationJumper>

Cmd+K / Ctrl+K fuzzy-search dialog. Mount in VitePress's layout-top slot; see theme setup. Per-spec URL prefixes are read from the provide set by enhanceAppWithOpenApi, so no props are needed for cross-link routing.

PropTypeDefaultDescription
placeholderstring'Jump to an operation or schema...'Input placeholder.
ariaLabelstring'Jump to an operation or schema'Dialog accessible label.

Programmatic API

buildSnippets()

Generate SDK snippets programmatically:

ts
import { buildSnippets } from 'vitepress-openapi-docs'

const snippets = buildSnippets(operation, {
  baseUrl: 'https://api.example.com',
  auth: { scheme: 'bearer', value: 'my-token' },
  exampleBody: '{"name": "test"}',
})

Snippet generators

Re-exported from vue-api-playground:

ts
import { toCurlSnippet, toFetch, toPython } from 'vitepress-openapi-docs'

Each takes a SnippetRequest:

ts
interface SnippetRequest {
  url: string
  method: string
  headers?: Record<string, string>
  body?: string
}

useAuthState()

Reactive auth state for a spec (advanced — for custom layouts):

ts
import { useAuthState, readStoredCredential } from 'vitepress-openapi-docs'

const auth = useAuthState('api')
auth.set({ scheme: 'bearer', value: 'my-token' })
auth.clear()

// Synchronous read
const cred = readStoredCredential('api')

Released under the MIT License.