Skip to content

Commit dc94025

Browse files
authored
Restructure "GitHub Setup" page and rename to "Project Structure" (#341)
1 parent f0b56cd commit dc94025

File tree

5 files changed

+153
-189
lines changed

5 files changed

+153
-189
lines changed

fern/products/sdks/fern-folder.mdx

Lines changed: 5 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
---
2-
title: Set up the Fern Folder
3-
description: Describes the fern folder structure
2+
title: Quickstart
3+
subtitle: Set up the fern folder
44
---
55

66
Configuring Fern starts with the `fern` folder, the root directory that contains
77
your API definitions, generators, and your CLI version.
88

9-
After you configure your `fern` folder, you'll be ready to start generating SDKs
10-
in different languages and [augmenting them with custom code](/sdks/overview/custom-code).
11-
129
## Set up the fern folder
1310

1411
<Steps>
@@ -30,90 +27,8 @@ in different languages and [augmenting them with custom code](/sdks/overview/cus
3027
{/* <Markdown src="/products/sdks/snippets/option-3-asyncapi.mdx"/> */}
3128
</AccordionGroup>
3229

33-
### Set up GitHub
34-
35-
Now, you're ready to [set up your GitHub repositories](/sdks/overview/github).
36-
37-
### Augment your SDK with custom code
38-
39-
Learn more about [adding custom code and utilizing a `.fernignore` file](/sdks/overview/custom-code).
30+
### Next: Set up your repository structure
4031

32+
Now that you have your `fern` folder initialized, [learn how to organize your repositories for SDK generation](/sdks/overview/github).
33+
4134
</Steps>
42-
43-
## Learn more about the initialized files
44-
45-
Every initialized `fern` directory has:
46-
* A `fern.config.json` file
47-
* A `generators.yml` file
48-
49-
### `fern.config.json`
50-
51-
This file stores the organization and the version of the Fern CLI that you are
52-
using.
53-
54-
```json
55-
{
56-
"organization": "imdb",
57-
"version": "<Markdown src="/products/sdks/snippets/fern-config-json-version.mdx"/>"
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-
<Info>
74-
See the [`generators.yml` reference page](/sdks/reference/generators-yml) for more information.
75-
</Info>
76-
77-
## Configure Multiple APIs
78-
79-
The fern folder can house multiple API definitions. Instead of placing your API
80-
definitions at the top level, you can nest them within an `apis` folder. Be sure
81-
to include a `generators.yml` file within each API folder that specifies the
82-
location of the API definition.
83-
84-
<Tabs>
85-
<Tab title="OpenAPI Definition">
86-
```bash
87-
fern/
88-
├─ fern.config.json
89-
├─ generators.yml
90-
└─ apis/
91-
└─ imdb/
92-
├─ generators.yml
93-
└─ openapi/
94-
├─ openapi.yml
95-
└─ disney/
96-
├─ generators.yml
97-
└─ openapi/
98-
├─ openapi.yml
99-
```
100-
</Tab>
101-
<Tab title="Fern Definition">
102-
```bash
103-
fern/
104-
├─ fern.config.json
105-
├─ generators.yml
106-
└─ apis/
107-
└─ imdb/
108-
├─ generators.yml
109-
└─ definition/
110-
├─ api.yml
111-
└─ imdb.yml
112-
└─ disney/
113-
├─ generators.yml
114-
└─ definition/
115-
├─ api.yml
116-
└─ disney.yml
117-
```
118-
</Tab>
119-
</Tabs>
Lines changed: 139 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,160 @@
11
---
2-
title: Structure your GitHub repositories
3-
description: Set up GitHub repositories for your SDKs
2+
title: Project structure
3+
description: An overview of the file and folder structure of a Fern SDKs project
44
---
55

6-
Before generating SDKs with Fern, you'll need to set up the proper GitHub
7-
repository structure to house your API definitions and SDK code so it's
8-
intuitive for you and your users to access, maintain, and update code.
6+
Before generating SDKs with Fern, set up the proper GitHub repository structure to house your API definitions and SDK code so it's intuitive for you and your users to access, maintain, and update code.
97

10-
<Steps>
11-
## Structuring your top-level repository
8+
## Repository architecture
129

13-
1. Identify or create a top-level GitHub repository where you want all of your
14-
SDK and API code to live.
15-
1. Install the [Fern GitHub App](https://github.com/apps/fern-api) on the
16-
top-level repository and all SDK repositories. Select **Configure**, then
17-
scroll down to **Repository Access**. Select **Only select repositories** and
18-
in the dropdown select the repository for your SDK. Click **Save**.
10+
Fern recommends a parent-child repository structure containing:
1911

20-
For example, your basic GitHub file structure should look something like this:
12+
- **Parent repository**: Contains your API definitions and SDK generation configuration
13+
- **Child repositories**: Separate repositories for each SDK (TypeScript, Python, Go, etc.)
2114

15+
```bash
16+
├─ company-repo # Parent repository
17+
│ └─ fern/
18+
│ ├─ fern.config.json
19+
│ ├─ apis/
20+
│ │ └─ sdks/
21+
│ │ └─ generators.yml # References child repos
22+
├─ typescript-sdk-repo # Child repository
23+
├─ python-sdk-repo # Child repository
24+
└─ go-sdk-repo # Child repository
2225
```
23-
├─ company-repo # Top-level repo for all SDKs
24-
├─ fern/
25-
├─ apis/
26-
├─ sdks/
27-
└── generators.yml # Contains settings for all SDKs
28-
```
29-
Your `generators.yml` file will contain a group for each of your SDKs. Each group points
30-
to the GitHub repository for the relevant SDK.
3126

32-
For example, the `group` for a TypeScript SDK might look like this:
27+
This separation allows you to manage API definitions centrally while keeping each SDK in its own repository for independent versioning and distribution.
3328

34-
```yaml title="generators.yml"
35-
ts-sdk:
36-
generators:
37-
- name: fernapi/fern-typescript-sdk
38-
version: 2.6.3
39-
github:
40-
repository: your-organization/your-typescript-repo
29+
<Info>
30+
For an example of this structure, see Cohere's [fern folder](https://github.com/cohere-ai/cohere-developer-experience/tree/23d6c541a01eb6b54dd9bb3588c805bb0e307713/fern) and [TypeScript](https://github.com/cohere-ai/cohere-typescript) and [Python](https://github.com/cohere-ai/cohere-python) child repositories.
31+
</Info>
32+
33+
## Core configuration files
34+
35+
[Initializing your `fern` folder](/sdks/overview/quickstart) creates two key configuration files:
36+
37+
### `fern.config.json`
38+
39+
This file stores your organization name and Fern CLI version:
40+
41+
```json
42+
{
43+
"organization": "your-organization",
44+
"version": "<Markdown src="/products/sdks/snippets/fern-config-json-version.mdx"/>"
45+
}
4146
```
4247

43-
For additional examples, see Cohere's [`generators.yml`
48+
### `generators.yml`
49+
50+
The `generators.yml` file specifies which SDKs to generate and where to publish them. It acts as the bridge between your API definitions and your SDK repositories.
51+
52+
<Info>
53+
For examples, see Cohere's [`generators.yml`
4454
file](https://github.com/cohere-ai/cohere-developer-experience/blob/23d6c541a01eb6b54dd9bb3588c805bb0e307713/fern/apis/sdks/generators.yml)
4555
and Vapi's [`generators.yml`
4656
file](https://github.com/VapiAI/docs/blob/9c674c2b16ba03e864e26673c5290c88048c9a7a/fern/apis/api/generators.yml).
57+
</Info>
58+
59+
60+
<Info>
61+
See the [`generators.yml` reference page](/sdks/reference/generators-yml) for complete configuration options.
62+
</Info>
4763

48-
<Info>You can also additionally configure the `github` section to whether Fern
49-
should commit and release, create a pull request, or push code to a branch when
50-
you make changes to your SDK code. See [GitHub
51-
Configuration](/sdks/reference/generators-yml#github-configuration) for more
52-
details. </Info>
53-
54-
## Structuring SDK-specific repositories
55-
56-
1. Create a new GitHub repository called `company-<language>` (or something
57-
similar) for each of your SDKs, if you haven't done so already.
58-
1. Install the [Fern GitHub App](https://github.com/apps/fern-api) on the
59-
top-level repository and all SDK repositories. Select **Configure**, then
60-
scroll down to **Repository Access**. Select **Only select repositories** and
61-
in the dropdown select the repository for your SDK. Click **Save**.
62-
63-
64-
The repository structure for a specific SDK should look similar to this:
65-
66-
```{6-11}
67-
├─ company-repo # Top-level repo for all SDKs
68-
├─ fern/
69-
├─ apis/
70-
├─ sdks/
71-
└── generators.yml # Contains settings for all SDKs
72-
├─ typescript-sdk-repo # Repository for a TypeScript SDK
73-
├─ .github/workflows/ # Contains GitHub Actions for publishing to package repositories, etc.
74-
├─ scripts/
75-
├─ src/
76-
├─ tests/
77-
└── .fernignore # Lists files that Fern shouldn't modify
78-
├─ python-sdk-repo
79-
└── go-sdk-repo
64+
## Parent repository structure
65+
66+
The parent repository contains your API definitions and the `generators.yml` file that references your child SDK repositories.
67+
68+
<CodeBlock title="Parent repository structure">
69+
```bash
70+
company-repo/
71+
├─ fern/
72+
│ ├─ fern.config.json
73+
│ ├─ apis/
74+
│ │ └─ sdks/
75+
│ │ └─ generators.yml # SDK generation configuration
8076
```
77+
</CodeBlock>
8178

82-
Fern generates most of the SDK files listed in this example repository (`scripts/`, `src/`, `tests`,
83-
`.fernignore`, etc.), including any custom code you added. You have to manually set up `.github/workflows` to execute actions, like publishing SDK versions to a package repository.
79+
Your `generators.yml` file contains a group for each SDK and points to the corresponding child repository:
8480

85-
For additional examples, see Cohere's [Python SDK repository](https://github.com/cohere-ai/cohere-python) and [Vapi's TypeScript SDK repository](https://github.com/VapiAI/server-sdk-typescript).
81+
```yaml title="generators.yml"
82+
groups:
83+
ts-sdk:
84+
generators:
85+
- name: fernapi/fern-typescript-sdk
86+
version: <Markdown src="/snippets/version-number-ts.mdx"/>
87+
github:
88+
repository: your-organization/typescript-sdk-repo
8689

87-
## Generate an SDK in your desired language
88-
89-
Once you've set up your GitHub repository structure, you can proceed with generating SDKs in your desired languages.
90-
91-
<CardGroup cols={3}>
92-
<Card title="TypeScript" icon={<img src="./images/icons/ts-light.svg" alt="TypeScript logo" className="h-6 w-6" noZoom />} href="/sdks/generators/typescript/quickstart">
93-
</Card>
94-
<Card title="Python" icon={<img src="./images/icons/python-light.svg" className="h-6 w-6" noZoom />} href="/sdks/generators/python/quickstart">
95-
</Card>
96-
<Card title="Go" icon={<img src="./images/icons/go-light.svg" className="h-6 w-6" noZoom />} href="/sdks/generators/go/quickstart">
97-
</Card>
98-
<Card title="Java" icon={<img src="./images/icons/java-light.svg" className="h-6 w-6" noZoom />} href="/sdks/generators/java/quickstart">
99-
</Card>
100-
<Card title=".NET" icon={<img src="./images/icons/csharp-light.svg" className="h-6 w-6" noZoom />} href="/sdks/generators/csharp/quickstart">
101-
</Card>
102-
<Card title="PHP" icon={<img src="./images/icons/php-light.svg" className="h-6 w-6" noZoom />} href="/sdks/generators/php/quickstart">
103-
</Card>
104-
<Card title="Ruby" icon={<img src="./images/icons/ruby-light.svg" className="h-6 w-6" noZoom />} href="/sdks/generators/php/quickstart">
105-
</Card>
106-
</CardGroup>
107-
108-
</Steps>
90+
python-sdk:
91+
generators:
92+
- name: fernapi/fern-python-sdk
93+
version: <Markdown src="/snippets/version-number-python.mdx"/>
94+
github:
95+
repository: your-organization/python-sdk-repo
96+
```
97+
98+
## Child repository structure
99+
100+
Each SDK has its own repository with the following structure:
109101
102+
<CodeBlock title="Child repository structure">
103+
```bash
104+
typescript-sdk-repo/ # Individual SDK repository
105+
├─ .github/workflows/ # Publishing workflows
106+
├─ scripts/
107+
├─ src/
108+
├─ tests/
109+
└─ .fernignore # Files Fern shouldn't modify
110+
```
111+
</CodeBlock>
112+
113+
Fern generates most of these files automatically, including preserving any custom code you've added.
114+
115+
## Setup instructions
116+
117+
1. **Create repositories**: Set up your parent repository and one child repository for each SDK
118+
2. **Install Fern GitHub App**: Install the [Fern GitHub App](https://github.com/apps/fern-api) on all repositories (parent and children)
119+
3. **Configure generators.yml**: Add each child repository to your `generators.yml` file
120+
121+
## Multiple API definitions
122+
123+
For multiple APIs, organize them in separate folders within the `apis` directory:
124+
125+
<Tabs>
126+
<Tab title="OpenAPI Definition">
127+
```bash
128+
fern/
129+
├─ fern.config.json
130+
├─ generators.yml
131+
└─ apis/
132+
└─ imdb/
133+
├─ generators.yml
134+
└─ openapi/
135+
├─ openapi.yml
136+
└─ disney/
137+
├─ generators.yml
138+
└─ openapi/
139+
├─ openapi.yml
140+
```
141+
</Tab>
142+
<Tab title="Fern Definition">
143+
```bash
144+
fern/
145+
├─ fern.config.json
146+
├─ generators.yml
147+
└─ apis/
148+
└─ imdb/
149+
├─ generators.yml
150+
└─ definition/
151+
├─ api.yml
152+
└─ imdb.yml
153+
└─ disney/
154+
├─ generators.yml
155+
└─ definition/
156+
├─ api.yml
157+
└─ disney.yml
158+
```
159+
</Tab>
160+
</Tabs>

fern/products/sdks/overview/typescript/quickstart.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ description: Get started quickly with the Fern TypeScript SDK.
55

66
Generate a TypeScript SDK by following the instructions on this page.
77

8-
<Info>
9-
This page assumes that you have:
10-
11-
* An initialized `fern` folder on your local machine. See [Set up the `fern`
12-
folder](/sdks/overview/quickstart).
13-
* A GitHub repository for your TypeScript SDK. See [Set up your GitHub repositories](/sdks/overview/github).
14-
</Info>
8+
<Markdown src="/products/sdks/snippets/setup-fern-folder-callout.mdx"/>
159

1610
<Steps>
1711

fern/products/sdks/sdks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ navigation:
77
- page: Quickstart
88
path: ./fern-folder.mdx
99
slug: quickstart
10-
- page: GitHub Setup
10+
- page: Project Structure
1111
path: ./github-setup.mdx
1212
slug: github
1313
- page: Adding Custom Code
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<Info>This guide assumes that you already have an initialized `fern` folder on
2-
your local machine. See [Set up the `fern` folder](/sdks/overview/quickstart) for more
3-
details.</Info>
1+
<Info>
2+
This page assumes that you have:
3+
4+
* An initialized `fern` folder on your local machine. See [Set up the `fern`
5+
folder](/sdks/overview/quickstart).
6+
* A GitHub repository for your TypeScript SDK. See [Project Structure](/sdks/overview/github).
7+
</Info>

0 commit comments

Comments
 (0)