mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
bbb1a08ed3
Co-authored-by: locadex-agent[bot] <217277504+locadex-agent[bot]@users.noreply.github.com>
86 lines
2.9 KiB
Plaintext
86 lines
2.9 KiB
Plaintext
---
|
||
title: "Speakeasy"
|
||
description: "在你的 API 操作台中自动生成并展示 SDK 代码示例。"
|
||
keywords: ["Speakeasy SDK", "autogenerated SDKs", "SDK code samples", "API playground integration"]
|
||
---
|
||
|
||
来自 Speakeasy SDK 的自动生成代码片段可直接集成到 Mintlify 的 API 参考文档中。这些 SDK 使用示例将显示在由 Mintlify 驱动的文档站点的[交互式操作台](/zh/api-playground/overview)中。
|
||
|
||
<Frame>
|
||

|
||
</Frame>
|
||
|
||
<div id="prerequisites">
|
||
## 前提条件
|
||
</div>
|
||
|
||
要将 Mintlify 与 Speakeasy 集成,你需要:
|
||
|
||
* 一个 [Mintlify 文档存储库](/zh/quickstart#creating-the-repository)。
|
||
* 一个由 Speakeasy 生成的 SDK,并已配置[自动代码示例 URL](https://www.speakeasy.com/docs/code-samples/automated-code-sample-urls)。
|
||
|
||
<div id="setting-up-the-integration">
|
||
## 设置集成
|
||
</div>
|
||
|
||
要将 Speakeasy 与 Mintlify 集成,你需要从注册中心获取该 API 的合并规范的公共 URL,并更新你的 `docs.json` 配置文件。
|
||
|
||
<div id="get-the-apis-combined-spec-public-url-from-the-registry">
|
||
### 从注册表获取 API 的合并规范公开 URL
|
||
</div>
|
||
|
||
前往你的 [Speakeasy 控制台](https://app.speakeasy.com),打开 **API Registry** 标签页。打开该 API 的 `*-with-code-samples` 条目。
|
||
|
||
<Frame>
|
||

|
||
</Frame>
|
||
|
||
<Note>
|
||
如果该条目未标记为 **Combined Spec**,请确保该 API 已配置[自动代码示例 URL](https://www.speakeasy.com/docs/code-samples/automated-code-sample-urls)。
|
||
</Note>
|
||
|
||
在该注册表条目的页面上,复制提供的公开 URL。
|
||
|
||
<Frame>
|
||

|
||
</Frame>
|
||
|
||
<div id="update-your-docsjson-configuration-file">
|
||
### 更新你的 `docs.json` 配置文件
|
||
</div>
|
||
|
||
将合并后的规范 URL 添加到 `docs.json` 文件中的 **Anchors** 或 **Tabs** 部分。
|
||
|
||
在 `docs.json` 文件中按如下方式更新 `anchor` 字段,将合并后的规范 URL 添加到对应锚点:
|
||
|
||
```json docs.json
|
||
{
|
||
"anchors": [
|
||
{
|
||
"name": "API 参考",
|
||
// !mark
|
||
"openapi": "SPEAKEASY_COMBINED_SPEC_URL",
|
||
"url": "api-reference",
|
||
"icon": "square-terminal"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
通过如下方式在 `docs.json` 文件中更新 `tab` 字段,将合并后的规范 URL 添加到一个标签页中:
|
||
|
||
```json docs.json
|
||
{
|
||
"tabs": [
|
||
{
|
||
"name": "API 参考",
|
||
"url": "api-reference",
|
||
// !mark
|
||
"openapi": "SPEAKEASY_COMBINED_SPEC_URL"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
现在,Speakeasy 生成的代码片段已可在你的 API 文档中查看,并可在演示区中交互使用。
|