Skip to content

Commit 49fec7c

Browse files
authored
Align SDKs and API Definitions project structure pages (#485)
1 parent cced951 commit 49fec7c

File tree

3 files changed

+55
-112
lines changed

3 files changed

+55
-112
lines changed
Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: The Fern Folder
2+
title: Project structure
33
description: Describes the Fern folder structure
44
---
55

@@ -15,22 +15,15 @@ fern/
1515
├─ fern.config.json # Root-level config for entire Fern project
1616
├─ generators.yml # Defines SDKs and docs to generate
1717
└─ spec-folder/ # definition, openapi, asyncapi, etc.
18-
└─ spec-file.yml # API specification file
18+
└─ spec-file.yml # API definition file
1919
```
2020

21-
<Info>
22-
For Fern Definition, your API configuration is split across two files: `api.yml` for API-wide configuration and separate `.yml` files for your actual endpoint and type definitions. See [What is a Fern Definition?](/api-definitions/ferndef/overview) for more information.
23-
24-
For the other specification formats ([OpenAPI](/api-definitions/openapi/overview), [AsyncAPI](/api-definitions/asyncapi/overview), [OpenRPC](/api-definitions/openrpc/overview), and [gRPC](/api-definitions/grpc/overview)), you'll have a single self-contained specification file.
25-
</Info>
26-
27-
<AccordionGroup>
28-
<Accordion title="What is the fern.config.json file?">
21+
### `fern.config.json file`
2922

3023
Every fern folder has a single `fern.config.json` file. This file stores the organization and
3124
the version of the Fern CLI that you are using.
3225

33-
```json
26+
```json title="fern.config.json"
3427
{
3528
"organization": "your-organization",
3629
"version": "0.31.2"
@@ -39,35 +32,22 @@ the version of the Fern CLI that you are using.
3932

4033
Every time you run a fern CLI command, the CLI downloads itself at the correct version to ensure
4134
determinism.
42-
</Accordion>
43-
<Accordion title="What is the generators.yml file?">
4435

45-
The `generators.yml` file includes information about where your API definition file is located. It also configures the SDKs you're generating for your API.
36+
### `generators.yml`
37+
38+
The `generators.yml` file includes information about where your API definition file is located. It also [configures the SDKs](/sdks/overview/github) you're generating for your API.
4639

47-
```yaml
40+
```yaml title="generators.yml"
4841
api:
4942
path: ./path/to/openapi.yml
5043
```
51-
</Accordion>
52-
</AccordionGroup>
5344
54-
## Multiple APIs
45+
### API definition file
5546
56-
The fern folder can house multiple API definitions. When you have multiple APIs, nest your definition files within an `apis` folder.
47+
For Fern Definition, your API configuration is split across two files: `api.yml` for API-wide configuration and separate `.yml` files for your actual endpoint and type definitions. See [What is a Fern Definition?](/api-definitions/ferndef/overview) for more information.
5748

58-
Each API must also have a separate `generators.yml` file that specifies the location of the API definition and configures SDK generation.
49+
For the other specification formats ([OpenAPI](/api-definitions/openapi/overview), [AsyncAPI](/api-definitions/asyncapi/overview), [OpenRPC](/api-definitions/openrpc/overview), and [gRPC](/api-definitions/grpc/overview)), you'll have a single self-contained specification file.
5950

60-
```bash
61-
fern/
62-
├─ fern.config.json
63-
├─ generators.yml # Optional: top-level configuration for all APIs
64-
└─ apis/
65-
└─ first-api/ # First API
66-
├─ generators.yml # Required: points to API spec
67-
└─ openapi/
68-
├─ openapi.yml # API Definition file
69-
└─ second-api/ # Second API
70-
├─ generators.yml # Required: points to API spec
71-
└─ openapi/
72-
├─ openapi.yml # API Definition file
73-
```
51+
## Multiple API definitions
52+
53+
<Markdown src="/snippets/multiple-apis.mdx" />

fern/products/sdks/github-setup.mdx

Lines changed: 23 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ Fern recommends a parent-child repository structure containing:
1515
```bash
1616
├─ company-repo # Parent repository
1717
│ └─ fern/
18-
│ ├─ fern.config.json
19-
│ ├─ apis/
20-
└─ sdks/
21-
└─ generators.yml # References child repos
18+
│ ├─ fern.config.json # Root-level config
19+
│ ├─ generators.yml # References child repos
20+
│ └─ definition/ # or openapi/, asyncapi/, etc.
21+
│ └─ api.yml # Your API definition
2222
├─ typescript-sdk-repo # Child repository
2323
├─ python-sdk-repo # Child repository
2424
└─ go-sdk-repo # Child repository
2525
```
2626

2727
This separation allows you to manage API definitions centrally while keeping each SDK in its own repository for independent versioning and distribution.
2828

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.
29+
<Info title="Examples">
30+
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.
3131
</Info>
3232

3333
## Core configuration files
3434

35-
[Initializing your `fern` folder](/sdks/overview/quickstart) creates two key configuration files:
35+
The parent repository contains a `fern/` folder that is initialized with your API definitions and a top-level `generators.yml` file.
3636

3737
### `fern.config.json`
3838

39-
This file stores your organization name and Fern CLI version:
39+
Every fern folder has a single `fern.config.json` file. This file stores the organization name and the version of the Fern CLI that you are using:
4040

4141
```json
4242
{
@@ -45,40 +45,13 @@ This file stores your organization name and Fern CLI version:
4545
}
4646
```
4747

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`
54-
file](https://github.com/cohere-ai/cohere-developer-experience/blob/23d6c541a01eb6b54dd9bb3588c805bb0e307713/fern/apis/sdks/generators.yml)
55-
and Vapi's [`generators.yml`
56-
file](https://github.com/VapiAI/docs/blob/9c674c2b16ba03e864e26673c5290c88048c9a7a/fern/apis/api/generators.yml).
57-
</Info>
58-
48+
Every time you run a fern CLI command, the CLI downloads itself at the correct version to ensure determinism.
5949

60-
<Info>
61-
See the [`generators.yml` reference page](/sdks/reference/generators-yml) for complete configuration options.
62-
</Info>
63-
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
76-
```
77-
</CodeBlock>
50+
### `generators.yml`
7851

79-
Your `generators.yml` file contains a group for each SDK and points to the corresponding child repository:
52+
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. For SDK generation, it contains a group for each SDK and points to the corresponding child repository:
8053

81-
```yaml title="generators.yml"
54+
```yaml
8255
groups:
8356
ts-sdk:
8457
generators:
@@ -95,11 +68,20 @@ groups:
9568
repository: your-organization/python-sdk-repo
9669
```
9770
71+
<Info title="Examples">
72+
See Cohere's [`generators.yml` file](https://github.com/cohere-ai/cohere-developer-experience/blob/23d6c541a01eb6b54dd9bb3588c805bb0e307713/fern/apis/sdks/generators.yml) and Vapi's [`generators.yml` file](https://github.com/VapiAI/docs/blob/9c674c2b16ba03e864e26673c5290c88048c9a7a/fern/apis/api/generators.yml).
73+
</Info>
74+
75+
See the [`generators.yml` reference page](/sdks/reference/generators-yml) for complete configuration options.
76+
77+
### API definition file
78+
79+
For information on how to structure your API definition files, see [Project structure (API Definitions)](/api-definitions/overview/project-structure).
80+
9881
## Child repository structure
9982

10083
Each SDK has its own repository with the following structure:
10184

102-
<CodeBlock title="Child repository structure">
10385
```bash
10486
typescript-sdk-repo/ # Individual SDK repository
10587
├─ .github/workflows/ # Publishing workflows
@@ -108,7 +90,6 @@ typescript-sdk-repo/ # Individual SDK repository
10890
├─ tests/
10991
└─ .fernignore # Files Fern shouldn't modify
11092
```
111-
</CodeBlock>
11293

11394
Fern generates most of these files automatically, including preserving any custom code you've added.
11495

@@ -120,41 +101,5 @@ Fern generates most of these files automatically, including preserving any custo
120101

121102
## Multiple API definitions
122103

123-
For multiple APIs, organize them in separate folders within the `apis` directory:
104+
<Markdown src="/snippets/multiple-apis.mdx" />
124105

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/snippets/multiple-apis.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
The fern folder can house multiple API definitions. When you have multiple APIs, nest your definition files within an `apis` folder.
2+
3+
Each API must also have a separate `generators.yml` file that specifies the location of the API definition and configures SDK generation.
4+
5+
```bash
6+
fern/
7+
├─ fern.config.json
8+
├─ generators.yml # Optional: top-level configuration for all APIs
9+
└─ apis/
10+
└─ first-api/ # First API
11+
├─ generators.yml # Required: points to API spec
12+
└─ openapi/
13+
├─ openapi.yml # API Definition file
14+
└─ second-api/ # Second API
15+
├─ generators.yml # Required: points to API spec
16+
└─ openapi/
17+
├─ openapi.yml # API Definition file
18+
```

0 commit comments

Comments
 (0)