The Fern Command Line Interface (Fern CLI) is an open source tool that enables you to interact with the Fern compiler using commands in your command-line shell. Use the Fern CLI to generate code from your API definition.
Fern compiler
Unlike most compilers, the Fern compiler does not produce a single output. Here are some examples of what the Fern compiler can output:
- A TypeScript Node.js SDK
- FastAPI server boilerplate
- A Postman Collection
- An OpenAPI Specification
To support the long and growing list of outputs, we've built the Fern Compiler to be modular. The core compiler is responsible for parsing and validating your API definition and producing the intermediate representation.
The remaining work is handled by generators. A Fern generator is a program that takes in an intermediate representation and outputs... something. Generators can be written in any language.
specify which generators you want the compiler to run using the special file
generators.yml
. You can view the list of available generators here.
Generator schema
In this section, we'll detail the different properties you need to include for a generator.
Name
Each generator has a unique name, e.g., fernapi/fern-typescript-node-sdk
.
Version
You must specify which version of the generator you want to use. This helps ensure consistent builds.
Default group
You can also specify a default-group
in generators.yml
:
Then, you can just run fern generate
to run the internal-sdks
generator(s).
Configuration
Some generators allow for custom configuration, which you can specify using the optional config
key.
Authentication required
Fern's CLI requires user authentication for code generation:
- If prompted, proceed with authentication by typing
y
and pressing enter. - Alternatively, initiate the process using
fern login
. This command will either prompt you to log in or confirm that you're already authenticated.
Once authenticated:
Permission Verification: Fern checks your credentials to grant access for specific actions, such as publishing your SDK to dedicated registries (e.g., npm.buildwithfern.com), syncing code to GitHub, or deploying a documentation site.
-
Proactive Support: Encountered an error? We can promptly intervene and assist with troubleshooting.
-
Enhancing User Experience: Fern collects usage analytics to improve the product.
Feedback: Have thoughts on this login requirements? Join the discussion on this GitHub Issue