For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
预约演示登录免费开始
  • 概览
    • 什么是 API 定义?
    • 项目结构
      • 概览
      • 覆盖层(Overlays)
      • 覆盖(Overrides)
      • 身份验证
      • 服务器
      • 同步您的规范
        • 概览
        • API 版本
        • 受众
        • 可用性
        • 基础路径
        • 默认值
        • 枚举描述、名称和可用性
        • API Explorer 控制
        • 全局请求头
        • 忽略元素
        • SDK 变量
        • SDK 方法名称
        • 参数名称
        • 属性名称
        • 幂等性
        • 分页
        • 重试行为
        • Schema 名称
        • 服务器名称和 URL 模板化
        • 模式名称
        • 服务器名称和 URL 模板化
      • OpenAPI generators.yml 参考
Checking status...
SOC2Soc 2 Type II
© 2026 Fern • Birch Solutions, Inc., a Postman company

Documentation

SDKsDocsAsk FernCLI Reference

API Definitions

OpenAPIAsyncAPIOpenRPCgRPC

Resources

BlogSupportPricing

Company

Brand KitPrivacy PolicyTerms of Service
LogoLogo
预约演示登录免费开始
在本页
  • 描述和可用性
  • 自定义名称
  • 自定义大小写
OpenAPI扩展

枚举描述、名称、大小写和可用性

||以 Markdown 格式查看|
此页面是否有帮助?
在仪表板中编辑
上一个

默认值

下一个

请求 + 响应示例

OpenAPI 原生不支持为枚举值添加描述。要在 Fern 中实现此功能,您可以使用 x-fern-enum 扩展。

描述和可用性

使用 description 为单个枚举值添加文档,使用 deprecated 将值标记为已弃用而不会弃用整个枚举。这些设置会传播到生成的 SDK 和文档网站中。

openapi.yml
1components:
2 schemas:
3 CardSuit:
4 enum:
5 - clubs
6 - diamonds
7 - hearts
8 - spades
9 x-fern-enum:
10 clubs:
11 description: 梅花花色
12 diamonds:
13 description: "已弃用。请使用红心。"
14 deprecated: true
15 hearts:
16 description: 红心花色
17 spades:
18 description: 黑桃花色

自定义名称

使用 name 字段自定义生成代码中枚举值的名称。当枚举值依赖符号字符而可能导致生成的代码无法编译时,这特别有用。

例如,以下 OpenAPI:

openapi.yml
1components:
2 schemas:
3 Operand:
4 enum:
5 - '>'
6 - '<'
7 x-fern-enum:
8 '>':
9 name: GreaterThan
10 description: 检查值是否大于
11 '<':
12 name: LessThan
13 description: 检查值是否小于

将生成:

operand.ts
1export enum Operand {
2 GreaterThan = ">",
3 LessThan = "<"
4}

自定义大小写

使用 casing 字段为每个目标语言的命名约定指定确切的大小写。这比仅使用 name 提供了更精细的控制,后者只为生成的代码设置单个默认名称。

casing 字段支持四个可选的子字段:

  • snake — snake_case 的覆盖(用于 Python 等语言)
  • camel — camelCase 的覆盖(用于 TypeScript/Java 等语言)
  • screamingSnake — SCREAMING_SNAKE_CASE 的覆盖(用于 Go 等语言)
  • pascal — PascalCase 的覆盖(用于 C# 等语言)
openapi.yml
1components:
2 schemas:
3 Status:
4 type: string
5 enum:
6 - active
7 - in-progress
8 x-fern-enum:
9 active:
10 description: 项目处于活动状态
11 in-progress:
12 name: InProgress
13 casing:
14 snake: in_progress
15 camel: inProgress
16 screamingSnake: IN_PROGRESS
17 pascal: InProgress

您可以将 casing 与 name 一起使用。name 字段设置默认生成的名称,而 casing 提供按语言的覆盖。如果两者都指定,casing 值对其各自的语言目标具有优先级。