The Fern Folder

Configuring fern starts with the fern folder. The fern folder contains your API definitions, generators, and your CLI version.

Directory structure

When you run fern init, your Fern folder will be initialized with the following files:

$fern/
> ├─ fern.config.json
> ├─ generators.yml
> └─ definition/
> ├─ api.yml
> └─ imdb.yml

If you want to initialize Fern with an OpenAPI Specification, run fern init --openapi path/to/openapi instead.

1fern/
2 ├─ fern.config.json
3 ├─ generators.yml # required on Fern version 0.41.0 and above
4 └─ openapi/
5 ├─ openapi.yml

fern.config.json

Every fern folder has a single fern.config.json file. This file stores the organization and the version of the Fern CLI that you are using.

1{
2 "organization": "imdb",
3 "version": "0.31.2"
4}

Every time you run a fern CLI command, the CLI downloads itself at the correct version to ensure determinism.

To upgrade the CLI, run fern upgrade. This will update the version field in fern.config.json

generators.yml

The generators.yml file can include information about where your API specification is located, along with which generators you are using, where each package gets published, as well as configuration specific to each generator.

Multiple APIs

The Fern folder is capable of housing multiple API definitions. Instead of placing your API definition at the top-level, you can nest them within an apis folder. Be sure to include a generators.yml file within each API folder that specifies the location of the API definition.

$fern/
> ├─ fern.config.json
> ├─ generators.yml
> └─ apis/
> └─ imdb/
> ├─ generators.yml
> └─ openapi/
> ├─ openapi.yml
> └─ disney/
> ├─ generators.yml
> └─ openapi/
> ├─ openapi.yml