Enum descriptions, names, casing, and availability

View as Markdown

OpenAPI doesn’t natively support adding descriptions to enum values. To do this in Fern you can use the x-fern-enum extension.

Descriptions and availability

Use description to add documentation to individual enum values and deprecated to mark values as deprecated without deprecating the entire enum. These propagate into the generated SDKs and docs website.

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: The clubs suit
12 diamonds:
13 description: "Deprecated. Use hearts instead."
14 deprecated: true
15 hearts:
16 description: The hearts suit
17 spades:
18 description: The spades suit

Custom names

Use the name field to customize the name of an enum value in generated code. This is particularly useful when enum values rely on symbolic characters that would otherwise cause generated code not to compile.

For example, the following OpenAPI:

openapi.yml
1components:
2 schemas:
3 Operand:
4 enum:
5 - '>'
6 - '<'
7 x-fern-enum:
8 '>':
9 name: GreaterThan
10 description: Checks if value is greater than
11 '<':
12 name: LessThan
13 description: Checks if value is less than

would generate:

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

Custom casing

Use the casing field to specify exact casing for each target language’s naming convention. This gives more granular control than name alone, which sets a single default name for generated code.

The casing field supports four optional sub-fields:

  • snake — override for snake_case (used in languages like Python)
  • camel — override for camelCase (used in languages like TypeScript/Java)
  • screamingSnake — override for SCREAMING_SNAKE_CASE (used in languages like Go)
  • pascal — override for PascalCase (used in languages like 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: The item is active
11 in-progress:
12 name: InProgress
13 casing:
14 snake: in_progress
15 camel: inProgress
16 screamingSnake: IN_PROGRESS
17 pascal: InProgress

You can use casing alongside name. The name field sets the default generated name, while casing provides per-language overrides. If both are specified, the casing values take precedence for their respective language targets.