> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJjZmYxYjNmMy01NzZlLTQ0M2MtYjFiNC1mMTQwNGUyYjM4MjgiLCJleHAiOjE3NzgzMTAzNjcsImlhdCI6MTc3ODMxMDA2N30.myPEO55QUPxs15smjHC8qnCpz3xiO9Xm-4MaSLN13MM
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 生成 OpenRPC 参考文档

> 使用 Fern Docs 从 OpenRPC 规范生成 OpenRPC 参考文档。

Fern 从 [OpenRPC](https://open-rpc.org/) 规范生成 OpenRPC 参考文档。

<Frame caption={<a href="https://www.alchemy.com/docs/data/nft-api/api-reference/nft-ownership-endpoints/get-nf-ts-for-owner-v-3">Alchemy 文档站点示例</a>}>
  <img src="file:f1c4a016-e5c7-4acc-b389-e69a6773f170" alt="Alchemy's OpenRPC API Reference Example" />
</Frame>

## 配置

<Steps>
  <Step title="设置项目结构">
    将您的 OpenRPC 规范文件（例如 `openrpc.yaml`）添加到 `/fern` 目录中，并创建一个引用它的 `generators.yml`：

    ```yaml generators.yml
    api:
      specs:
        - openrpc: ./openrpc.yml
    ```
  </Step>

  <Step title="将 OpenRPC 参考文档添加到导航中">
    在 `docs.yml` 的导航中添加 `- api: API Reference`：

    ```yml docs.yml
    navigation:
      - api: API Reference
    ```
  </Step>

  <Step title="自定义布局">
    有关配置选项和布局自定义的完整列表，请参见[自定义 API 参考文档布局](/learn/docs/api-references/customize-api-reference-layout)。
  </Step>
</Steps>

### 包含多个 OpenRPC 参考文档

要在文档中包含多个 OpenRPC 定义，请使用 `api-name` 属性。`api-name` 对应包含您的 OpenRPC 定义的文件夹名称。

<Files>
  <Folder name="fern" defaultOpen>
    <File name="fern.config.json" />

    <File name="docs.yml" />

    <Folder name="wallet-api" defaultOpen>
      <File name="openrpc.yml" comment="Wallet OpenRPC spec" />

      <File name="generators.yml" />
    </Folder>

    <Folder name="nft-api" defaultOpen>
      <File name="openrpc.yml" comment="NFT OpenRPC spec" />

      <File name="generators.yml" />
    </Folder>
  </Folder>
</Files>

```yaml title="docs.yml"
navigation:
  - api: Wallet API
    api-name: wallet-api
  - api: NFT API
    api-name: nft-api
```

### 配置属性

<ParamField path="api.specs[].openrpc" required>
  您的 OpenRPC 规范文件的路径。如果您的项目公开多个 JSON-RPC API，您可以包含多个 OpenRPC 规范。
</ParamField>