Configuring Fern starts with the fern folder, the root directory that contains
your API definitions, generators, and your CLI version.
After you configure your fern folder, you’ll be ready to start generating SDKs
in different languages.
Run the following command to install the CLI tool or update it to the latest version:
You can initialize your fern folder with either a Fern Definition or OpenAPI specification.
You can always convert a Fern Definition to OpenAPI or OpenAPI to a Fern Definition later on.
Initialize the fern folder using your OpenAPI Specification. Run one of the following commands based on your spec’s location.
Fern can handle both JSON and YML formats for OpenAPI specifications, and the —openapi flag accepts either format, so you can use whichever format your API spec is available in.
--organization <YourOrganization> configures your organization name in fern.config.json. This is required in order to successfully generate your SDK.
This creates a fern folder in your current directory with the OpenAPI Specification. The exact folder structure might look different depending on your initial input files.
Initialize the fern folder using the Fern Definition by running the following command:
--organization <YourOrganization> configures your organization
name in fern.config.json. This is required in order to successfully
generate your SDK. This creates a fern folder in your current directory with the Fern Definition.
imdb.yml contains an example movies API. If you’re just
generating an SDK for test purposes, you can leave this file as it is. To
generate an SDK for your own API instead of the example movies API,
replace imdb.yml with your own endpoints, types, and errors before
proceeding with the rest of this page. Every initialized fern directory has:
fern.config.json filegenerators.yml filefern.config.jsonThis file stores the organization and the version of the Fern CLI that you are using.
Every time you run a fern CLI command, the CLI downloads itself at the correct version to ensure determinism.
fern upgrade. This will update the version field in fern.config.json generators.ymlThe generators.yml file specifies which SDKs Fern should generate from your
API specification. For each generator, it specifies where the package is
published and configures customizations like package metadata, output locations,
and generation settings.
See the generators.yml reference page for more information.
The fern folder can house multiple API definitions. Instead of placing your API
definitions 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.