Skip to navigation

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
components:
schemas:
CardSuit:
enum:
- clubs
- diamonds
- hearts
- spades
x-fern-enum:
clubs:
description: The clubs suit
diamonds:
description: "Deprecated. Use hearts instead."
deprecated: true
hearts:
description: The hearts suit
spades:
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
components:
schemas:
Operand:
enum:
- '>'
- '<'
x-fern-enum:
'>':
name: GreaterThan
description: Checks if value is greater than
'<':
name: LessThan
description: Checks if value is less than

would generate:

operand.ts
export enum Operand {
GreaterThan = ">",
LessThan = "<"
}

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
components:
schemas:
Status:
type: string
enum:
- active
- in-progress
x-fern-enum:
active:
description: The item is active
in-progress:
name: InProgress
casing:
snake: in_progress
camel: inProgress
screamingSnake: IN_PROGRESS
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.