x-codeSamples. Holocron shows them as extra tabs in the Request example panel next to the generated cURL snippet.x-codeSamples entry (your SDK snippets)examples from the spec (JSON payloads)OpenAPI operation │ ▼ ┌─────────────────────────────────────────┐ │ Request example │ │ cURL │ TypeScript │ Python │ … │ │ ┌───────────────────────────────────┐ │ │ │ await client.users.list() │ │ │ └───────────────────────────────────┘ │ └─────────────────────────────────────────┘
<Tabs sync> groups). Pick TypeScript once and the next endpoint opens on
TypeScript when that tab exists.x-codeSamples on any path method:123456789101112131415161718192021paths: /users: get: summary: List users x-codeSamples: - lang: TypeScript label: TypeScript source: | import { Acme } from '@acme/sdk' const client = new Acme() await client.users.list({ role: 'editor' }) - lang: Python label: Python source: | from acme import Acme client = Acme() client.users.list(role="editor") - lang: bash label: CLI source: | acme users list --role editor
| Field | Required | Description |
lang | yes | Language id for highlighting (TypeScript, python, bash, …) |
source | yes | Inline snippet body (string). Use a string, not a $ref; external refs are not resolved for samples. |
label | no | Tab title. Defaults to lang. |
x-codeSamples.openapi.code_samples: 'mintlify' in stainless.yml, publish the OpenAPI URL from the Release tab, and set that file or path as your tab openapi value.*-with-code-samples) and point openapi at that document.@hey-api/openapi-ts) can generate a typed SDK and write x-codeSamples back into a source OpenAPI JSON. Point Holocron at that decorated file.1npm install -D @hey-api/openapi-ts
12345678910111213141516171819202122232425// openapi-ts.config.ts import { defineConfig } from '@hey-api/openapi-ts' export default defineConfig({ input: './openapi.yaml', output: { path: './src/client', // Writes a decorated copy of the input spec after intents run. // Path is resolved as path.resolve(output.path, source.path, fileName + '.json') source: { path: '../..', // project root when output is ./src/client fileName: 'openapi.with-samples', }, }, plugins: [ '@hey-api/client-fetch', { name: '@hey-api/sdk', // Generate TypeScript usage snippets and attach them via x-codeSamples examples: { language: 'TypeScript', }, }, ], })
output.source writes the input document after intents run. The SDK plugin’s examples option appends each generated snippet to that operation’s x-codeSamples.path.resolve(output.path, source.path, fileName + '.json'). With the config above that is openapi.with-samples.json at the project root. If source.path is '..' instead, the file would be src/openapi.with-samples.json.123456// package.json { "scripts": { "openapi:sdk": "openapi-ts" } }
1npm run openapi:sdk
1234{ "tab": "API Reference", "openapi": "openapi.with-samples.json" }
openapi.yaml ──► openapi-ts (sdk.examples) ──► openapi.with-samples.json │ ▼ docs.json openapi field │ ▼ Request example tabs
example/api.yaml with x-codeSamples on List users and Create user. Open the API Reference tab locally and switch the Request example tabs between cURL and the SDK languages.label short. The Request example tab bar is narrow; long labels force horizontal scroll.x-codeSamples on a few important endpoints and leave the rest as cURL only. Mixed specs work fine.