Schema names

OpenAPI allows you to define inlined schemas that do not have names.

Inline type in openapi.yml
1components:
2 schemas:
3 Movie:
4 type: object
5 properties:
6 name:
7 type: string
8 cast:
9 type: array
10 items:
11 type: object
12 properties:
13 firstName:
14 type: string
15 lastName:
16 type: string
17 age:
18 type: integer

Fern automatically generates names for all the inlined schemas. For example, in this example, Fern would generate the name CastItem for the inlined array item schema.

Auto-generated name
1export interface Movie {
2 name?: string;
3 cast?: CastItem[];
4}
5
6export interface CastItem {
7 firstName?: string;
8 lastName?: string;
9 age?: integer;
10}

If you want to override the generated name, you can use the extension x-fern-type-name.

openapi.yml
1components:
2 schemas:
3 Movie:
4 type: object
5 properties:
6 name:
7 type: string
8 cast:
9 type: array
10 items:
11 type: object
12 x-fern-type-name: Person
13 properties:
14 firstName:
15 type: string
16 lastName:
17 type: string
18 age:
19 type: integer

This would replace CastItem with Person and the generated code would read more idiomatically:

Overridden name
1export interface Movie {
2 name?: string;
3 cast?: Person[];
4}
5
6export interface Person {
7 firstName?: string;
8 lastName?: string;
9 age?: integer;
10}