Skip to main content

Imports

Imports allow you to reference types, errors, and ids from other Fern Definitions.

Example of using imports

Let's say that we've got a movies.yml where we've already defined a MovieId.

# movies.yml

types:
MovieId: string

We now want to create a new file called actors.yml that includes every movie an Actor has had a role in. We don't want to redefine MovieId, instead we want to reference what we already defined above. We can accomplish this by using an import.

# actors.yml

imports:
movies: movies.yml

types:
ActorId: string

Actor:
properties:
id: ActorId
name: string
movies: list<movies.MovieId>

In the last line above, movies. informs which import to reference and MovieId is the id that we're referencing. While this example shows importing a type from another file, you can also import errors.