Skip to content

Custom Slots

The following slots are available on both OAOperation and OASpec. They let you override the default operation layout with your own content. For component-specific props and events, see OAOperation and OASpec.

Available Slots and Props

Each slot receives scoped props you can use in your template. Below is the reference for every slot, its purpose, and its props.

Custom header content above the operation.

PropTypeDescription
operationObjectParsed operation object from the OpenAPI spec
methodStringHTTP method (e.g. get, post)
pathStringPath pattern (e.g. /users/{id})
deprecatedBooleanWhether the operation is marked deprecated

tags

Custom tags display.

PropTypeDescription
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern
tagsArrayList of tag names for the operation

path

Custom path and method display (e.g. endpoint URL and method badge).

PropTypeDescription
operationIdStringUnique operation identifier
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern
hideBaseUrlBooleanWhether to hide the base URL
deprecatedBooleanWhether the operation is deprecated
serversArrayAvailable server URLs
baseUrlStringCurrently selected base URL for the playground

description

Custom description content (supports markdown).

PropTypeDescription
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern

security

Custom security requirements display.

PropTypeDescription
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern
securityUiArraySecurity schemes available for the operation
selectedSchemeIdStringCurrently selected security scheme ID

parameters

Custom parameters section (path, query, header, cookie).

PropTypeDescription
operationIdStringUnique operation identifier
parametersArrayParsed parameters for the operation

request-body

Custom request body section.

PropTypeDescription
operationIdStringUnique operation identifier
requestBodyObjectParsed request body schema/content

responses

Custom responses section.

PropTypeDescription
operationIdStringUnique operation identifier
responsesObjectParsed responses (status codes and content)

playground

Custom playground / try-it section.

PropTypeDescription
operationIdStringUnique operation identifier
pathStringPath pattern
methodStringHTTP method
parametersArrayOperation parameters
requestBodyObjectRequest body schema
securityUiArraySecurity schemes for the playground
serversArrayAvailable server URLs

code-samples

Custom code samples section.

PropTypeDescription
operationIdStringUnique operation identifier
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern
codeSamplesArrayPre-generated code samples (language + code)

branding

Custom branding footer (e.g. vitepress-openapi credit).

PropTypeDescription
operationIdStringUnique operation identifier
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern

Custom footer content below the operation.

PropTypeDescription
operationIdStringUnique operation identifier
operationObjectParsed operation object
methodStringHTTP method
pathStringPath pattern

Using slot props

Use Vue's scoped slot syntax to access these props. The same pattern works for both OAOperation and OASpec:

vue
<OAOperation operation-id="getUserById">
  <template #header="{ operation, method, path, deprecated }">
    <div class="my-header">
      <span class="method">{{ method.toUpperCase() }}</span>
      <span class="path">{{ path }}</span>
      <span v-if="deprecated" class="badge">Deprecated</span>
    </div>
  </template>
</OAOperation>

With OASpec, the same slot customizes every operation:

vue
<OASpec>
  <template #header="{ operation, method, path }">
    <h3>{{ method }} {{ path }}</h3>
  </template>
</OASpec>

Full example

In the following example, we demonstrate how to use all available slots in the OAOperation component. Each slot is populated with a SlotDebugger component that displays the slot properties for debugging purposes.

markdown
---
aside: false
outline: false
title: vitepress-openapi
---

<OAOperation operationId="createArtist">

<template #header="header">
<SlotDebugger :slotProps="header" title="header" />
</template>

<template #tags="tags">
<SlotDebugger :slotProps="tags" title="tags" />
</template>

<template #path="path">
<SlotDebugger :slotProps="path" title="path" />
</template>

<template #description="description">
<SlotDebugger :slotProps="description" title="description" />
</template>

<template #security="security">
<SlotDebugger :slotProps="security" title="security" />
</template>

<template #parameters="parameters">
<SlotDebugger :slotProps="parameters" title="parameters" />
</template>

<template #request-body="requestBody">
<SlotDebugger :slotProps="requestBody" title="request-body" />
</template>

<template #responses="responses">
<SlotDebugger :slotProps="responses" title="responses" />
</template>

<template #playground="playground">
<SlotDebugger :slotProps="playground" title="playground" />
</template>

<template #code-samples="codeSamples">
<SlotDebugger :slotProps="codeSamples" title="code-samples" />
</template>

<template #branding="branding">
<SlotDebugger :slotProps="branding" title="branding" />
</template>

<template #footer="footer">
<SlotDebugger :slotProps="footer" title="footer" />
</template>

</OAOperation>

header slot

Slot Props
PropertyTypeValue
keynumber0
operationobject
{...}
methodstringpost
pathstring/api/v1/artists
deprecatedundefinedundefined

path slot

Slot Props
PropertyTypeValue
operationIdstringcreateArtist
operationobject
{...}
methodstringpost
pathstring/api/v1/artists
hideBaseUrlbooleantrue
deprecatedundefinedundefined
serversobject
[...]
baseUrlstringhttps://stoplight.io/mocks/enzonotario/argentine-rock/122547792

description slot

Slot Props
PropertyTypeValue
keynumber1
operationobject
{...}
methodstringpost
pathstring/api/v1/artists

security slot

Slot Props
PropertyTypeValue
keynumber0
operationobject
{...}
methodstringpost
pathstring/api/v1/artists
securityUiobject
[...]
selectedSchemeIdstringbearerAuth

request-body slot

Slot Props
PropertyTypeValue
keynumber0
operationIdstringcreateArtist
requestBodyobject
{...}

responses slot

Slot Props
PropertyTypeValue
keynumber0
operationIdstringcreateArtist
responsesobject
{...}

playground slot

Slot Props
PropertyTypeValue
operationIdstringcreateArtist
pathstring/api/v1/artists
methodstringpost
parametersobject
[...]
requestBodyobject
{...}
securityUiobject
[...]
serversobject
[...]

code-samples slot

Slot Props
PropertyTypeValue
operationIdstringcreateArtist
operationobject
{...}
methodstringpost
pathstring/api/v1/artists
codeSamplesundefinedundefined

branding slot

Slot Props
PropertyTypeValue
keynumber2
operationIdstringcreateArtist
operationobject
{...}
methodstringpost
pathstring/api/v1/artists

footer slot

Slot Props
PropertyTypeValue
keynumber3
operationIdstringcreateArtist
operationobject
{...}
methodstringpost
pathstring/api/v1/artists