Enum descriptions and names

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

In the example below, we’ve added some descriptions to enum values. These descriptions will propagate into the generated SDK 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: Some docs about clubs
12 spades:
13 description: Some docs about spades

x-fern-enum also supports a name field that allows you to customize the name of the enum in code. This is particularly useful when you have enums that 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}