Getting started
Install
npm install -g fern-api
The fern/
directory
The fern/
directory contains your API definition. This generally lives in your
backend repo, but you can also have an independent repo dedicated to your API (like Raven’s).
In the root of your repo, run:
fern init
This will create the following folder structure in your project:
fern/
├─ fern.config.json # root-level configuration
└─ api/ # your API
├─ generators.yml # generators you're using
└─ definition/
├─ api.yml # API-level configuration
└─ imdb.yml # endpoints, types, and errors
Already have an OpenAPI spec?
You can import an existing OpenAPI spec by running
fern init --openapi /path/to/openapi.yml
More information here.
Generating an SDK
To generate the TypeScript SDK and an OpenAPI spec, run:
fern generate
By default, generators.yml
is configured to generate a TypeScript SDK and an
OpenAPI spec. You can read more about generation on the fern generate
page.
Defining your API
Your Fern Definition is a set of YAML files that describe your API. You can learn more about this in the Define your API section.
Running the Fern compiler
The Fern compiler takes your Fern Definition and generates useful outputs, like SDKs. You can learn more about configuring outputs in the Compiler section.