generators.yml 配置模式
generators.yml 配置模式
generators.yml 文件有两个作用:它声明您的 API 定义(OpenAPI/AsyncAPI 必需),并配置 SDK 生成,包括生成哪些语言、发布位置以及如何自定义每个 SDK。
要在编辑器中启用智能 YAML 验证和自动补全功能,请在 generators.yml 文件顶部添加模式指令。
auth-schemes
为您的 SDK 和 API 浏览器 定义身份验证方法,您的端点可以引用这些方法。在 generators.yml 中定义的身份验证方案优先于在规范中定义的身份验证方案。
定义身份验证方案后,必须使用 api.auth 将其作为默认值应用于所有端点。或者,如果需要针对不同语言的不同身份验证行为,可以为单个 SDK 定义身份验证。
选择自定义 header(API 密钥)、HTTP Basic、Bearer token 或 OAuth 2.0 身份验证:
Header
Configure authentication using custom HTTP headers, such as API keys or tokens.
The name of the HTTP header to use for authentication.
A descriptive name for this authentication scheme.
The type of the header value.
A prefix to prepend to the header value (e.g., "Bearer " or "Token ").
Environment variable name containing the authentication value. When specified, the generated SDK will automatically scan for this environment variable at initialization.
Basic
Configure HTTP Basic authentication using username and password credentials.
Must be set to "basic" for Basic authentication schemes.
Configuration for the username credential.
Custom parameter name for the username in the generated SDK. If not specified, defaults to "username". Use this to provide more descriptive or domain-specific parameter names like "clientId", "userEmail", or "merchantId".
Configuration for the password credential.
Custom parameter name for the password in the generated SDK. If not specified, defaults to "password". Use this to provide more descriptive or domain-specific parameter names like "clientSecret", "apiKey", or "merchantKey".
Environment variable name that the SDK will automatically scan for the username or password value. When this environment variable is present, users don’t need to explicitly provide the username parameter. Follow naming conventions like YOUR_APP_USERNAME or SERVICE_CLIENT_ID.
Bearer token
Configure Bearer token authentication for API access.
Must be set to "bearer" for Bearer token authentication schemes.
Configuration for the bearer token.
A descriptive name for the token.
Environment variable name containing the bearer token. When specified, the generated SDK will automatically scan for this environment variable at initialization.
OAuth client credentials
For Fern Definition, you can configure OAuth authentication either in generators.yml or directly in your api.yml file. For OpenAPI, OAuth must be configured in generators.yml.
Configure OAuth 2.0 client credentials authentication. Optionally configure a refresh-token endpoint for token renewal without re-authentication.
Must be set to "oauth" for OAuth authentication schemes.
The OAuth 2.0 grant type. Currently only "client-credentials" is supported.
OAuth scopes to request when obtaining access tokens (e.g., "read:users", "write:orders").
Environment variable name containing the OAuth client ID. When specified, the generated SDK will automatically scan for this environment variable at initialization.
Environment variable name containing the OAuth client secret. When specified, the generated SDK will automatically scan for this environment variable at initialization.
Prefix added to the access token in the Authorization header (e.g., "Bearer" results in "Authorization: Bearer <token>"). Useful when your API expects a custom format.
HTTP header name used to send the access token. Defaults to "Authorization" but can be customized if your API uses a different header (e.g., "X-API-Token").
get-token
Specifies the endpoint that exchanges client credentials for an access token. This endpoint is called automatically when the SDK client is initialized.
The endpoint that issues access tokens, such as 'auth.get_token' or 'POST /oauth/token'. If your API uses namespaces, prefix with the namespace and :: (e.g., 'payments::POST /oauth/token').
Maps OAuth parameter names to your API’s request field names. Use this when your token endpoint expects different field names than the OAuth standard (e.g., your API uses clientId instead of client_id).
The request field name for the client ID in your API (e.g., "clientId", "client_id").
The request field name for the client secret in your API (e.g., "clientSecret", "client_secret").
The request field name for scopes in your API (e.g., "scope", "scopes").
Maps your API’s response field names to OAuth standard names. Use this when your API returns tokens with different field names (e.g., accessToken instead of access_token).
The response field name for the access token in your API (e.g., "accessToken", "access_token").
The response field name for token expiration time in seconds (e.g., "expiresIn", "expires_in"). When present, the SDK automatically refreshes tokens before expiration.
The response field name for the refresh token in your API (e.g., "refreshToken", "refresh_token"). Required if using the refresh-token flow.
refresh-token
Specifies the endpoint that exchanges a refresh token for a new access token. When configured, the SDK automatically uses this endpoint to renew expired tokens without re-sending credentials. If not configured, the SDK will re-authenticate using get-token when tokens expire.
The endpoint that refreshes access tokens (e.g., "POST /oauth/refresh" or "auth.refreshToken"). If your API uses namespaces, prefix with the namespace and :: (e.g., "payments::POST /oauth/refresh").
Maps OAuth parameter names to your API’s request field names for the refresh flow.
The request field name for the refresh token in your API (e.g., "refreshToken", "refresh_token").
Maps your API’s refresh response field names to OAuth standard names.
The response field name for the new access token (e.g., "accessToken", "access_token").
The response field name for the new token’s expiration time in seconds (e.g., "expiresIn", "expires_in").
The response field name if your API issues a new refresh token with each refresh (token rotation).
api
定义 API 规范(OpenAPI、AsyncAPI 等)以及如何解析它。对于 Fern 定义,不需要 API 引用 — Fern 自动检测您的规范。
auth
为所有端点设置默认身份验证方案。该值必须引用在 auth-schemes 中定义的方案名称。这将覆盖在 OpenAPI 规范中定义的任何安全方案。
使用此配置,所有生成的 SDK 都将要求使用 BearerAuth 方案进行身份验证:
您还可以使用生成器级别的 api.auth 设置为单个生成器覆盖身份验证。
headers
包含在所有 API 请求中的全局 header。这是在 OpenAPI 规范中配置全局 header 的替代方案。您可以将 header 指定为简单的字符串值,或作为具有代码生成附加配置的对象。
简单字符串值
带类型信息的高级配置
environments
不同部署目标的环境配置。
settings
应用于给定类型的所有规范(例如,所有 OpenAPI 规范)的设置。可以在规范或生成器级别覆盖。优先级:生成器级别设置覆盖规范级别设置,规范级别设置覆盖全局设置。
例如,使用此功能确保所有 OpenAPI 规范的解析行为一致。有关可用设置,请参阅下面的规范类型文档。
规范类型
每种规范类型(OpenAPI、AsyncAPI 等)都支持各种配置选项,包括规范文件位置、命名空间、覆盖和特定类型的设置。
OpenAPI
openapi
OpenAPI 规范文件的路径。
origin
用于拉取更新的 API 定义源 URL。有关如何设置自动同步的说明,请参阅 同步您的 OpenAPI 规范。
overlays
OpenAPI Overlay 文件的路径。Overlay 遵循 OpenAPI Overlay 规范,是自定义 OpenAPI 规范的推荐方法。
overrides
OpenAPI 覆盖 文件的路径,或按顺序应用的多个覆盖文件路径列表。建议使用 overlays 来实现基于标准的方法。
namespace
规范的命名空间。用于配置 包含多个 API 版本的单个包。
settings
此单独规范的 OpenAPI 特定生成设置。要在所有 OpenAPI 规范中应用相同的设置,请改用全局 api.settings。
settings.title-as-schema-name
是否将 OpenAPI 定义中模式的标题用作 Fern 中类型的名称。
settings.inline-path-parameters
是否在生成的内联请求中包含路径参数。
settings.inline-all-of-schemas
是否在代码生成期间内联 allOf 模式。当为 true 时,Fern 递归访问 allOf 模式定义并将它们内联到子模式中。当为 false 时,allOf 模式通过继承进行扩展。
启用此设置允许子模式覆盖父属性要求。例如,子模式可以将父级的必需属性标记为可选。如果没有此设置,Fern 会忽略子模式的可选声明,而是保留父模式的要求。
settings.prefer-undiscriminated-unions-with-literals
是否首选包含字面量的无区别联合。
settings.only-include-referenced-schemas
是否仅在生成的 SDK 中包含由端点引用的模式(树摇动)。
settings.respect-nullable-schemas
保留 API 定义设置中的可空模式。当为 false 时,可空模式被视为可选。
settings.object-query-parameters
启用解析深层对象查询参数。
settings.wrap-references-to-nullable-in-optional
控制是否将对可空模式的引用包装在可选类型中。当为 false 时,可空引用被视为可以为 null 的必需字段。
settings.coerce-optional-schemas-to-nullable
控制在代码生成期间是否将可选模式强制转换为可空类型。当为 false 时,可选和可空被视为不同的概念。
settings.respect-readonly-schemas
启用在 OpenAPI 规范中探索只读模式。
settings.respect-forward-compatible-enums
启用在 OpenAPI 规范中遵循前向兼容枚举。
settings.use-bytes-for-binary-response
启用对二进制响应使用 bytes 类型。默认为文件流。
settings.default-form-parameter-encoding
表单参数的默认编码。选项:form、json。
settings.additional-properties-defaults-to
配置当模式中没有明确定义时,additionalProperties 应默认为什么。
settings.type-dates-as-strings
如果为 true,将格式为 date 的字符串转换为字符串。如果为 false,转换为日期。
settings.preserve-single-schema-oneof
如果为 true,保留具有单个模式的 oneOf 结构。如果为 false,展开它们。
settings.filter
settings.filter.endpoints
要包含在生成的 SDK 中的端点。以 METHOD /path 格式指定端点(例如,POST /users、GET /users/{id})。只有列出的端点才会包含在生成的 SDK 中;所有其他端点将被排除。如果您的 API 使用 命名空间,请使用命名空间和 :: 前缀(例如,payments::POST /users)。
settings.example-generation.request.max-depth
控制为可选属性生成示例的最大深度。深度为 0 意味着不会为任何可选属性生成示例。
settings.example-generation.response.max-depth
控制在响应中为可选属性生成示例的最大深度。
settings.coerce-enums-to-literals
控制在代码生成期间是否将枚举转换为字面量类型。当为 false(默认值)时,枚举作为枚举类型保留,维护 OpenAPI 规范中的原始枚举结构。当为 true 时,枚举被强制转换为字面量类型,这对于生成的代码中更简单的类型表示很有用。
settings.idiomatic-request-names
控制自动生成的请求名称的命名约定。启用时,在请求名称中将动词置于名词之前(例如,UsersListRequest 变为 ListUsersRequest),遵循更符合习惯的命名模式。
settings.resolve-aliases
内联类型别名以简化生成的 SDK。启用时,通过直接用其底层类型替换简单别名来减少不必要的类型定义。对于具有许多基本类型或简单类型别名的 OpenAPI 规范很有用。
设置为 true 以内联所有别名,或使用带有 except 数组的对象来保留特定的类型别名:
settings.group-environments-by-host
启用时,按主机将服务器分组到统一环境中,使具有多种协议(REST、WebSocket 等)的 API 能够共享环境配置。环境 URL ID 使用服务器名称,仅在需要解决冲突时添加路径或协议后缀。
AsyncAPI
asyncapi
AsyncAPI 规范文件的路径。
origin
用于拉取更新的 API 定义源 URL。
overrides
AsyncAPI 覆盖文件的路径,或按顺序应用的多个覆盖文件的路径列表。
namespace
规范的命名空间。对于配置具有多个 API 版本的单个包很有用。
settings
此单个规范的 AsyncAPI 特定生成设置。要在所有 AsyncAPI 规范中应用相同的设置,请改用全局 api.settings。
settings.message-naming
用于 AsyncAPI 消息的消息命名版本。选项:v1、v2。
settings.title-as-schema-name
是否使用 AsyncAPI 定义中模式的标题作为 Fern 中类型的名称。
settings.respect-nullable-schemas
在 API 定义设置中保留可为 null 的模式。当为 false 时,可为 null 的模式被视为可选的。
settings.idiomatic-request-names
控制自动生成的请求名称的命名约定。启用时,在请求名称中将动词放在名词之前(例如,UsersListRequest 变为 ListUsersRequest),遵循更惯用的命名模式。
settings.wrap-references-to-nullable-in-optional
控制是否将对可为 null 模式的引用包装在可选类型中。当为 false 时,可为 null 的引用被视为可以为 null 的必需字段。
settings.coerce-optional-schemas-to-nullable
控制在代码生成期间是否将可选模式强制转换为可为 null 类型。当为 false 时,可选和可为 null 被视为不同的概念。
settings.group-environments-by-host
启用时,按主机将服务器分组到统一环境中,使具有多个协议(REST、WebSocket 等)的 API 能够共享环境配置。环境 URL ID 使用服务器名称,仅在需要解决冲突时才添加路径或协议后缀。
gRPC/proto buffers
root
到 .proto 目录根目录的路径(例如 proto)。必须指定到包开始的位置。例如,如果您的包是 package.test.v1,文件路径为 protos/package/test/v1/test_file.proto,那么根目录应该是 protos/
target
到目标 .proto 文件的路径(例如 proto/user/v1/user.proto)。省略此参数将为整个根文件夹生成文档。
overrides
重写配置文件的路径,或者按顺序应用的多个重写文件的路径列表。仅用于 SDK 生成,不用于文档生成。
local-generation
是否在本地编译 .proto 文件。默认使用远程生成(false)。启用时,您必须在您的机器上或在您的 CI/CD 环境(例如 GitHub Actions) 中安装 buf。
OpenRPC
Conjure
conjure
Conjure 规范文件的路径。
whitelabel
发布不带 Fern 品牌的生成 SDK 的配置。启用时,从生成的代码中删除所有对 Fern 的提及,并允许在您自己的品牌下发布。
username
用于提交和将白标 SDK 代码发布到 GitHub 存储库的 GitHub 用户名。这应该是对您的目标存储库具有写入权限的帐户的用户名。
与 GitHub 帐户关联的电子邮件地址。此电子邮件将在发布白标 SDK 代码时在 Git 提交中使用,并应与您的 GitHub 帐户设置中配置的电子邮件匹配。
token
具有适当存储库访问权限的 GitHub 个人访问令牌 (PAT)。令牌应具有 repo 范围权限,以允许读取和写入存储库来发布白标 SDK。
metadata
包含在所有生成的 SDK 中的包元数据,如描述和作者。或者,您可以为单个 SDK 定义元数据。
description
将包含在包元数据中的 SDK 简要描述。此描述帮助用户在包存储库中发现您的 SDK 时了解您的 SDK 的功能。
authors
将在生成的 SDK 包元数据中被认可的作者列表。
name
在 SDK 包元数据中被认可的作者的全名。
作者的电子邮件地址。这将包含在包元数据中,包管理器可能会使用它作为联系信息。
readme
控制所有 SDK 中生成的 README 文件的内容,允许您自定义 SDK 文档的内容和结构。
bannerLink
URL for a banner image or link that appears at the top of the README.
introduction
Custom introduction text that appears at the beginning of the README.
apiReferenceLink
URL to your external API documentation or reference guide.
apiName
Name of the API that appears in the README. Will appear as Your Api Name SDK or Your Api Name API throughout the README. Defaults to organization name if not set.
exampleStyle
Controls whether usage examples show only required parameters (minimal) or all parameters (comprehensive). Currently only supported for Java SDKs. File an issue to request additional languages.
disabledSections
Sections to disable in the README. Supported values: "contributing".
features
Organizes endpoints into named feature sections within the README. Each feature creates a dedicated section with example code snippets for the specified endpoints.
Endpoint configuration
Specifies which endpoint’s code snippet to showcase as the primary example in the README.
defaultEndpoint.method
HTTP method of the default endpoint (e.g., GET, POST, PUT, DELETE).
defaultEndpoint.path
Endpoint path for the default example (e.g., /users, /auth/login).
defaultEndpoint.stream
Whether the endpoint is a streaming endpoint. Defaults to false.
Custom sections
Define a custom section in the generated README for a specific SDK.
customSections.title
The title of the custom section as it will appear in the README.
customSections.language
The target SDK language for this section. The custom section will only appear in README files generated for the specified language.
customSections.content
The Markdown content of the custom section. You can use template variables in the format {{ variable }} that will be dynamically replaced with values specific to each SDK language when the README is generated.
Available template variables by language:
default-group
未指定时使用的生成器组。
default-group
autorelease
全局启用或禁用 Fern Autorelease 以进行自动化 SDK 发布。或者,您可以为单个 SDK 配置自动发布。
autorelease
设置为 true 启用自动发布,false 禁用它。每个生成器的设置覆盖此全局配置。
aliases
定义映射到多个生成器组的快捷方式,允许您使用单个命令运行多个组。当您运行 fern generate --group <alias> 时,别名中的所有组并行运行。您也可以将别名设置为 default-group。
aliases
一个映射,其中每个键是别名名称,值是组名称列表。每个组名称必须引用在 groups 部分中定义的组。
groups
组织用户定义的生成器集合,通常按环境(如”production”、“staging”)或语言(如”typescript”、“python”)分组。您还可以创建别名以使用单个命令运行多个组。
audiences
基于受众标签过滤生成的 SDK 中包含的 API 元素。只有在您的 API 规范中标记为指定受众的端点、模式和属性才会被包含。没有此过滤器,无论端点的受众标签如何,都会包含所有端点。
要使用受众,首先使用 OpenAPI 中的 x-fern-audiences 或 Fern 定义中的 audiences 标记您的 API 元素,然后在这里指定要包含的受众。
对于 OpenAPI,您还可以使用 settings.filter 在规范级别配置基于路径的过滤。
reviewers
为单个 SDK 设置代码审查者。或者,您可以为所有 SDK 全局配置审查者。
teams
GitHub team names that should review generated code.
users
GitHub users that should review generated code.
teams.name
Name of a GitHub team.
users.name
Name of a GitHub user.
generators
特定组的生成器设置。
Fern 生成器包名称(例如,fernapi/fern-typescript-sdk)。与 image 互斥。
要使用的生成器的特定版本
启用智能大小写转换,保留数字和常见编程模式:
- 数字保持不变(例如,
v2而不是v_2,getUsersV2而不是getUsersV_2) - 首字母缩略词得到保留(例如,
CustomerID而不是CustomerId) - 首字母缩写词保持正确(例如,
HTTPSConnection保持HTTPSConnection)
image
一个已识别的 Fern 生成器名称(例如,fern-python-sdk)。IR 版本解析需要此项。
容器注册表主机名和可选命名空间(例如,ghcr.io/your-org)。CLI 在拉取时构造完整的镜像引用为 {registry}/{name}:{version}。例如,使用 registry: ghcr.io/your-org、name: fern-python-sdk 和 version: 4.0.0,CLI 拉取 ghcr.io/your-org/fern-python-sdk:4.0.0。
config
特定语言的配置选项。
output
发布生成的 SDK 的位置。
npm
将 TypeScript SDK 发布到 npm 注册表。
设置为”npm”以发布到 NPM
自定义 NPM 注册表 URL
NPM 包名称(例如,“@myorg/api-sdk”)
用于发布的 NPM 身份验证令牌
Maven
将 Java SDK 发布到 Maven 存储库。
设置为”maven”以发布到 Maven
Maven 存储库 URL(可选,默认为 Maven Central)
“groupId:artifactId”格式的 Maven 工件坐标
存储库身份验证用户名
存储库身份验证密码
包签名的 GPG 签名配置
用于包签名的 GPG 密钥 ID
GPG 密钥密码
GPG 密钥内容
PyPI
将 Python SDK 发布到 Python Package Index。
设置为”pypi”以发布到 PyPI
自定义 PyPI 注册表 URL(可选,默认为 PyPI)
Python 包名称(例如,“myorg-api-sdk”)
用于发布的 PyPI 身份验证令牌
PyPI 用户名(令牌身份验证的替代方案)
PyPI 密码(令牌身份验证的替代方案)
包的额外 PyPI 特定元数据
用于 PyPI 搜索和发现的包关键字
包文档链接
项目主页链接
NuGet
将 .NET SDK 发布到 NuGet 存储库。
设置为”nuget”以发布到 NuGet
自定义 NuGet feed URL(可选,默认为 nuget.org)
NuGet 包名称(例如,“MyOrg.ApiSdk”)
用于发布到 feed 的 NuGet API 密钥
RubyGems
将 Ruby SDK 发布到 RubyGems 注册表。
设置为”rubygems”以发布到 RubyGems
自定义 RubyGems 注册表 URL(可选,默认为 rubygems.org)
Ruby gem 包名称(例如,“myorg_api_sdk”)
用于发布的 RubyGems API 密钥(需要”Push rubygem”权限)
注意: RubyGems API 密钥需要”Push rubygem”权限,理想情况下还需要”index”和”yank rubygem”权限。如果启用了 MFA,请确保 MFA 设置不要求为 API 密钥使用提供 MFA。
Postman
将 API 集合发布到 Postman 工作区。
设置为”postman”以发布到 Postman
用于工作区访问的 Postman API 密钥
将发布集合的目标 Postman 工作区 ID
要更新的现有集合 ID(如果未指定则创建新集合)
本地文件系统
将生成的 SDK 保存到本地文件系统而不是发布。
设置为”local-file-system”以本地输出
生成的文件将保存的本地目录路径
github
使用 github 配置指定如何在 GitHub 中生成 SDK。
指定 mode 以指定 Fern 如何处理您的代码更改。对于云生成,使用 repository 指定 GitHub 存储库。对于自托管生成,改用 uri 和 token。
Release(默认)
Fern 生成您的代码,提交到 main 分支,并标记新版本。
repository
您在 GitHub 中的存储库名称。
mode
branch
您在 GitHub 中的分支名称。
license
生成的 SDK 的软件许可证。
reviewers
指定哪些团队和用户应审查生成的代码。请参阅审查者配置。
Pull request(推荐)
Fern 生成您的代码,提交到新分支,并打开 PR 进行审查。要发布,您必须合并 PR 并标记 GitHub 版本。
repository
您在 GitHub 中的存储库名称。
mode
branch
您在 GitHub 中的分支名称。
license
生成的 SDK 的软件许可证。
reviewers
指定哪些团队和用户应审查生成的代码。请参阅审查者配置。
Push
Fern 生成您的代码并将其推送到您指定的分支。
repository
您在 GitHub 中的存储库名称。
mode
branch
您在 GitHub 中的分支名称。
license
生成的 SDK 的软件许可证。
reviewers
指定哪些团队和用户应审查生成的代码。请参阅审查者配置。
自托管
对于自托管 SDK 生成,使用 uri 和 token 而不是 repository 配置 github 属性。
uri
您的 GitHub 存储库的完整 URL(例如,https://github.com/your-org/your-repo)。
token
具有存储库写入权限的 GitHub 个人访问令牌。使用环境变量引用(例如,${GITHUB_TOKEN})。
mode
如何发布更改:push 直接提交到分支,pull-request 打开 PR 进行审查。
branch
提交或拉取请求的目标分支。
metadata
指定单个 SDK 的元数据。或者,您可以为所有 SDK 全局配置元数据。
package-description
您生成的 SDK 功能及其关键特性的简要描述。这出现在 package.json 描述字段和包注册表列表中。
包维护者或支持团队的联系电子邮件。
reference-url
指向 SDK 的综合文档、API 参考或入门指南的 URL。
author
创建和维护 SDK 的个人开发者、团队或组织的名称。
license
生成的 SDK 的软件许可证。
autorelease
为单个 SDK 启用或禁用 Fern Autorelease。或者,您可以为所有 SDK 全局配置自动发布。
autorelease
设置为 true 为此生成器启用自动发布,false 禁用它。每个生成器的设置覆盖全局 autorelease 配置。
snippets
为特定生成器配置代码片段。
path
生成的代码片段文件的路径。
覆盖 API 身份验证设置
使用 api 配置为特定 SDK 覆盖身份验证设置。
单一身份验证方案
多个身份验证选项
允许用户使用多种方法中的任何一种进行身份验证:
any
用户可以选择任何一种方法的身份验证方案列表。每个项可以是字符串引用("api-key")或方案对象(scheme: "api-key")。
自定义身份验证方案
使用 auth-schemes 定义自定义身份验证方案。您为自定义方案定义名称,然后指定身份验证方法(header、basic、bearer 或 oauth)。
Header 身份验证
Configure authentication using custom HTTP headers, such as API keys or tokens.
The name of the HTTP header to use for authentication.
A descriptive name for this authentication scheme.
The type of the header value.
A prefix to prepend to the header value (e.g., "Bearer " or "Token ").
Environment variable name containing the authentication value. When specified, the generated SDK will automatically scan for this environment variable at initialization.
Basic 身份验证
Configure HTTP Basic authentication using username and password credentials.
Must be set to "basic" for Basic authentication schemes.
Configuration for the username credential.
Custom parameter name for the username in the generated SDK. If not specified, defaults to "username". Use this to provide more descriptive or domain-specific parameter names like "clientId", "userEmail", or "merchantId".
Configuration for the password credential.
Custom parameter name for the password in the generated SDK. If not specified, defaults to "password". Use this to provide more descriptive or domain-specific parameter names like "clientSecret", "apiKey", or "merchantKey".
Environment variable name that the SDK will automatically scan for the username or password value. When this environment variable is present, users don’t need to explicitly provide the username parameter. Follow naming conventions like YOUR_APP_USERNAME or SERVICE_CLIENT_ID.
Bearer Token 身份验证
Configure Bearer token authentication for API access.
Must be set to "bearer" for Bearer token authentication schemes.
Configuration for the bearer token.
A descriptive name for the token.
Environment variable name containing the bearer token. When specified, the generated SDK will automatically scan for this environment variable at initialization.
OAuth Client Credentials
For Fern Definition, you can configure OAuth authentication either in generators.yml or directly in your api.yml file. For OpenAPI, OAuth must be configured in generators.yml.
Configure OAuth 2.0 client credentials authentication. Optionally configure a refresh-token endpoint for token renewal without re-authentication.
Must be set to "oauth" for OAuth authentication schemes.
The OAuth 2.0 grant type. Currently only "client-credentials" is supported.
OAuth scopes to request when obtaining access tokens (e.g., "read:users", "write:orders").
Environment variable name containing the OAuth client ID. When specified, the generated SDK will automatically scan for this environment variable at initialization.
Environment variable name containing the OAuth client secret. When specified, the generated SDK will automatically scan for this environment variable at initialization.
Prefix added to the access token in the Authorization header (e.g., "Bearer" results in "Authorization: Bearer <token>"). Useful when your API expects a custom format.
HTTP header name used to send the access token. Defaults to "Authorization" but can be customized if your API uses a different header (e.g., "X-API-Token").
get-token
Specifies the endpoint that exchanges client credentials for an access token. This endpoint is called automatically when the SDK client is initialized.
The endpoint that issues access tokens, such as 'auth.get_token' or 'POST /oauth/token'. If your API uses namespaces, prefix with the namespace and :: (e.g., 'payments::POST /oauth/token').
Maps OAuth parameter names to your API’s request field names. Use this when your token endpoint expects different field names than the OAuth standard (e.g., your API uses clientId instead of client_id).
The request field name for the client ID in your API (e.g., "clientId", "client_id").
The request field name for the client secret in your API (e.g., "clientSecret", "client_secret").
The request field name for scopes in your API (e.g., "scope", "scopes").
Maps your API’s response field names to OAuth standard names. Use this when your API returns tokens with different field names (e.g., accessToken instead of access_token).
The response field name for the access token in your API (e.g., "accessToken", "access_token").
The response field name for token expiration time in seconds (e.g., "expiresIn", "expires_in"). When present, the SDK automatically refreshes tokens before expiration.
The response field name for the refresh token in your API (e.g., "refreshToken", "refresh_token"). Required if using the refresh-token flow.
refresh-token
Specifies the endpoint that exchanges a refresh token for a new access token. When configured, the SDK automatically uses this endpoint to renew expired tokens without re-sending credentials. If not configured, the SDK will re-authenticate using get-token when tokens expire.
The endpoint that refreshes access tokens (e.g., "POST /oauth/refresh" or "auth.refreshToken"). If your API uses namespaces, prefix with the namespace and :: (e.g., "payments::POST /oauth/refresh").
Maps OAuth parameter names to your API’s request field names for the refresh flow.
The request field name for the refresh token in your API (e.g., "refreshToken", "refresh_token").
Maps your API’s refresh response field names to OAuth standard names.
The response field name for the new access token (e.g., "accessToken", "access_token").
The response field name for the new token’s expiration time in seconds (e.g., "expiresIn", "expires_in").
The response field name if your API issues a new refresh token with each refresh (token rotation).
reviewers
为所有 SDK 全局设置代码审查者。或者,您可以为单个 SDK 配置审查者。
teams
GitHub team names that should review generated code.
users
GitHub users that should review generated code.
teams.name
Name of a GitHub team.
users.name
Name of a GitHub user.