> 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.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI5NzQxYmJkNS1hNDk5LTRjNzgtYmY3OS1hMzA5NTlhZGEzZTUiLCJleHAiOjE3Nzg0OTA4NzUsImlhdCI6MTc3ODQ5MDU3NX0.wmYv7LLmbfD8l66qHboAi__YQzTZgb0mv92AB73ZT2M
>
> 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.

# 自定义 SDK 方法名

> 使用 `x-fern-sdk-method-name` 和 `x-fern-sdk-group-name` 来精细调整 SDK 命名。

使用 `x-fern-sdk-group-name` 和 `x-fern-sdk-method-name` 扩展来控制端点在 SDK 中的组织方式。

<Note title="Fern 自动解析 `operationId`">
  如果没有扩展存在，Fern 使用您的操作 ID 来生成 SDK 方法名。将操作 ID 格式化为 `{tag_name}_{operation_name}`（例如：`users_get`）来自动生成像 `users.get()` 这样的方法。如果操作 ID 不以标签开头，Fern 将直接使用它作为方法名。
</Note>

在下面的示例中，Fern 将为 `POST /users` 端点生成一个名为 `client.users.create()` 的方法。

```yaml title="openapi.yaml" {4-5}
paths:
  /users:
    post:
      x-fern-sdk-group-name: users
      x-fern-sdk-method-name: create
```

### 顶级方法

如果您省略 `x-fern-sdk-group-name` 扩展，生成的 SDK 方法将位于客户端的根级别，而不是嵌套在资源组下。在下面的示例中，Fern 将生成一个名为 `client.send()` 的方法：

```yaml title="openapi.yaml" {4}
paths:
  /send:
    post:
      x-fern-sdk-method-name: send
```

### 多级嵌套

<Note>
  查看 merge.dev 如何使用嵌套组 [这里](https://github.com/merge-api/merge-node-client?tab=readme-ov-file#create-link-token)。
</Note>

如果您添加多个 `x-fern-sdk-group-name` 扩展，那么生成的 SDK 将嵌套组名。生成的 SDK 方法保持组名的顺序。

在下面的示例中，Fern 将生成一个名为 `client.users.notifications.send()` 的方法：

```yaml title="openapi.yaml"
paths:
  /users/notifications:
    post:
      x-fern-sdk-group-name:
        - users
        - notifications
      x-fern-sdk-method-name: send
```