Skip to content

Commit 9e562e9

Browse files
authored
(sdks) Update versioned API options (#1236)
1 parent b6129b8 commit 9e562e9

File tree

1 file changed

+17
-36
lines changed

1 file changed

+17
-36
lines changed

fern/products/api-def/pages/project-structure.mdx

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ groups:
8787
github:
8888
repository: company/user-api-typescript
8989
```
90+
<Info>
91+
You can use this same pattern for API versioning. See [Versioned APIs](#versioned-apis) below.
92+
</Info>
93+
9094
</Accordion>
9195
<Accordion title="Combined SDKs from multiple APIs">
9296
@@ -125,48 +129,29 @@ api:
125129
openapi: payments-api/openapi.yml
126130
```
127131
</Accordion>
128-
<Accordion title="Versioned APIs in the same SDK">
132+
<Accordion title="Versioned APIs">
129133
130-
Use this approach when you need to support multiple API versions simultaneously in your SDK.
134+
When supporting multiple API versions, you can publish them as separate packages or combine them into a single package with namespaces.
131135
132-
#### Option 1: Branch-based versioning
136+
#### Option 1: Separate packages for each API version
133137
134-
Each API version is maintained as a separate spec that publishes to a different branch of a single SDK repository. This approach allows you to release updates for older API versions independently and manage each as a different major version of your SDK (v1.x.x, v2.x.x).
138+
Use this approach when you want each API version to be independently installable (e.g., `@company/sdk-v1`, `@company/sdk-v2`). This use case follows the [Separate SDKs for each API](#separate-sdks-for-each-api) pattern.
135139

136140
```bash
137141
fern/
138142
├─ fern.config.json
139143
└─ apis/
140-
├─ v1/
141-
│ ├─ generators.yml # Configures v1 SDK
142-
│ └─ openapi.yml
143-
└─ v2/
144-
├─ generators.yml # Configures v2 SDK
145-
└─ openapi.yml
144+
├─ v1/
145+
│ ├─ generators.yml # Configures v1 SDKs
146+
│ └─ openapi.yml
147+
└─ v2/
148+
├─ generators.yml # Configures v2 SDKs
149+
└─ openapi.yml
146150
```
147151

148-
Each API version must have its own `generators.yml` file that targets a [specific branch](/sdks/reference/generators-yml#github):
149-
150-
<Tabs>
151-
<Tab title="apis/v1/generators.yml">
152-
153-
```yaml title="apis/v1/generators.yml" {11}
154-
api:
155-
specs:
156-
- openapi: openapi.yml
157-
groups:
158-
ts-sdk:
159-
generators:
160-
- name: fernapi/fern-typescript-sdk
161-
github:
162-
repository: company/sdk
163-
mode: push
164-
branch: v1 # Targets v1 branch
165-
```
166-
</Tab>
167-
<Tab title="apis/v2/generators.yml">
152+
Each API must have its own `generators.yml` file:
168153

169-
```yaml title="apis/v2/generators.yml" {11}
154+
```yaml title="apis/v1/generators.yml"
170155
api:
171156
specs:
172157
- openapi: openapi.yml
@@ -175,12 +160,8 @@ groups:
175160
generators:
176161
- name: fernapi/fern-typescript-sdk
177162
github:
178-
repository: company/sdk
179-
mode: pull-request
180-
branch: v2 # Targets v2 branch
163+
repository: company/sdk-v1
181164
```
182-
</Tab>
183-
</Tabs>
184165

185166
#### Option 2: Namespace-based versioning
186167

0 commit comments

Comments
 (0)