mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
fbdd913d8e
* Add translation tracker for stale translations audit Generated-By: mintlify-agent * translations: add missing pages and update content for es, fr, zh Phase 1: Add translations for 4 new API analytics pages (feedback-by-page, searches, views, visitors) in es, fr, and zh. Phase 2: Update 3 pages with content changes: - agent/workflows: add "Disable a workflow" subsection - ai/skillmd: add 24-hour generation note - editor/publish: add AI PR title tip, reformat publishing workflows, promote "Publish your changes" heading from h3 to h2 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * update descriptions * translations * translations * translations * Delete TRANSLATION_TRACKER.md * translations * a * a * translations * translations * translations * translations * translations * translations * translations * translations * Update use-cases.mdx * translations * translations * Update ai-native.mdx * Update accordions.mdx * Update accordions.mdx * Update accordions.mdx * translations * translations * Update fonts.mdx * translations * translations: update SEO descriptions for es, fr, zh (150 pages) Update the description: frontmatter field across 150 pages × 3 languages to match the current English descriptions updated on 2026-03-31. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> Co-authored-by: Ethan Palm <56270045+ethanpalm@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.5 KiB
Plaintext
50 lines
1.5 KiB
Plaintext
---
|
|
title: "添加 SDK 示例"
|
|
description: "为你的 API 文档添加 SDK 代码示例,使用 Speakeasy 和 Stainless 自动生成的多语言示例。"
|
|
keywords: ["x-codeSamples", "SDK examples"]
|
|
---
|
|
|
|
如果用户通过 SDK 而不是直接通过网络请求与你的 API 交互,你可以使用 `x-codeSamples` 扩展在 OpenAPI 文档中添加代码示例,并将其展示在 OpenAPI 页面中。
|
|
|
|
将此属性添加到任何请求方法。它具有以下模式。
|
|
|
|
<ParamField body="lang" type="string" required>
|
|
代码示例所使用的编程语言。
|
|
</ParamField>
|
|
|
|
<ParamField body="label" type="string">
|
|
示例的标签。在为同一端点提供多个示例时很有用。
|
|
</ParamField>
|
|
|
|
<ParamField body="source" type="string" required>
|
|
示例的源代码。
|
|
</ParamField>
|
|
|
|
下面是一个植物追踪应用的代码示例,该应用同时提供 Bash CLI 工具和 JavaScript SDK。
|
|
|
|
```yaml
|
|
paths:
|
|
/plants:
|
|
get:
|
|
# ...
|
|
x-codeSamples:
|
|
- lang: bash
|
|
label: 列出所有未浇水的植物
|
|
source: |
|
|
planter list -u
|
|
- lang: javascript
|
|
label: 列出所有未浇水的植物
|
|
source: |
|
|
const planter = require('planter');
|
|
planter.list({ unwatered: true });
|
|
- lang: bash
|
|
label: 列出所有盆栽植物
|
|
source: |
|
|
planter list -p
|
|
- lang: javascript
|
|
label: 列出所有盆栽植物
|
|
source: |
|
|
const planter = require('planter');
|
|
planter.list({ potted: true });
|
|
```
|