Skip to content

Commit 13c9d76

Browse files
authored
Add page on Fern Folder (#75)
1 parent ba2db6d commit 13c9d76

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

fern/products/sdks/fern-folder.mdx

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Overview of the Fern Folder
3+
description: Describes the Fern folder structure
4+
---
5+
6+
Configuring Fern starts with the `fern` folder, the root directory that contains
7+
your API definitions, generators, and your CLI version.
8+
9+
After you configure your `fern` folder, you'll be ready to start generating SDKs
10+
in different languages.
11+
12+
## Directory structure
13+
14+
You can initialize your Fern folder with either a Fern Definition or OpenAPI specification.
15+
16+
<Info>
17+
You can always convert a Fern Definition to OpenAPI or OpenAPI to a Fern Definition later on.
18+
</Info>
19+
20+
The `fern` directory is initialized with:
21+
* A `fern.config.json` file
22+
* A `generators.yml` file
23+
* Either a `definition/` (for a Fern Definition spec) or `openapi/` (for an OpenAPI spec) directory that contains your API specification files.
24+
25+
<AccordionGroup>
26+
<Accordion title="Initializing with the Fern Definition">
27+
When you run `fern init`, your Fern folder will be initialized with the following files:
28+
```bash
29+
fern/
30+
├─ fern.config.json
31+
├─ generators.yml
32+
└─ definition/
33+
├─ api.yml
34+
└─ imdb.yml
35+
```
36+
</Accordion>
37+
<Accordion title="Initializing with OpenAPI">
38+
If you want to initialize Fern with an OpenAPI Specification, run `fern init --openapi path/to/openapi` instead.
39+
```yaml
40+
fern/
41+
├─ fern.config.json
42+
├─ generators.yml # required on Fern version 0.41.0 and above
43+
└─ openapi/
44+
├─ openapi.yml
45+
```
46+
</Accordion>
47+
</AccordionGroup>
48+
49+
### `fern.config.json`
50+
51+
Every fern folder has a single `fern.config.json` file. This file stores the organization and
52+
the version of the Fern CLI that you are using.
53+
54+
```json
55+
{
56+
"organization": "imdb",
57+
"version": "0.31.2"
58+
}
59+
```
60+
61+
Every time you run a fern CLI command, the CLI downloads itself at the correct version to ensure
62+
determinism.
63+
64+
<Note>To upgrade the CLI, run `fern upgrade`. This will update the version field in `fern.config.json` </Note>
65+
66+
### `generators.yml`
67+
68+
The `generators.yml` file specifies which SDKs Fern should generate from your
69+
API specification. For each generator, it specifies where the package is
70+
published and configures customizations like package metadata, output locations,
71+
and generation settings.
72+
73+
## Configuring Multiple APIs
74+
75+
The Fern folder can house multiple API definitions. Instead of placing your API
76+
definitions at the top level, you can nest them within an `apis` folder. Be sure
77+
to include a `generators.yml` file within each API folder that specifies the
78+
location of the API definition.
79+
80+
<Tabs>
81+
<Tab title="OpenAPI Definition">
82+
```bash
83+
fern/
84+
├─ fern.config.json
85+
├─ generators.yml
86+
└─ apis/
87+
└─ imdb/
88+
├─ generators.yml
89+
└─ openapi/
90+
├─ openapi.yml
91+
└─ disney/
92+
├─ generators.yml
93+
└─ openapi/
94+
├─ openapi.yml
95+
```
96+
</Tab>
97+
<Tab title="Fern Definition">
98+
```bash
99+
fern/
100+
├─ fern.config.json
101+
├─ generators.yml
102+
└─ apis/
103+
└─ imdb/
104+
├─ generators.yml
105+
└─ definition/
106+
├─ api.yml
107+
└─ imdb.yml
108+
└─ disney/
109+
├─ generators.yml
110+
└─ definition/
111+
├─ api.yml
112+
└─ disney.yml
113+
```
114+
</Tab>
115+
</Tabs>

fern/products/sdks/sdks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ navigation:
33
contents:
44
- page: Introduction
55
path: ./introduction.mdx
6+
- page: Overview of the Fern Folder
7+
path: ./fern-folder.mdx
68
- link: Customer Showcase
79
href: https://buildwithfern.com/showcase
810
- section: Generators

0 commit comments

Comments
 (0)