diff --git a/fern/products/api-def/pages/project-structure.mdx b/fern/products/api-def/pages/project-structure.mdx index 3ff1d98f7..ec8da4df8 100644 --- a/fern/products/api-def/pages/project-structure.mdx +++ b/fern/products/api-def/pages/project-structure.mdx @@ -87,6 +87,10 @@ groups: github: repository: company/user-api-typescript ``` + + You can use this same pattern for API versioning. See [Versioned APIs](#versioned-apis) below. + + @@ -125,48 +129,29 @@ api: openapi: payments-api/openapi.yml ``` - + -Use this approach when you need to support multiple API versions simultaneously in your SDK. +When supporting multiple API versions, you can publish them as separate packages or combine them into a single package with namespaces. -#### Option 1: Branch-based versioning +#### Option 1: Separate packages for each API version -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). +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. ```bash fern/ ├─ fern.config.json └─ apis/ - ├─ v1/ - │ ├─ generators.yml # Configures v1 SDK - │ └─ openapi.yml - └─ v2/ - ├─ generators.yml # Configures v2 SDK - └─ openapi.yml + ├─ v1/ + │ ├─ generators.yml # Configures v1 SDKs + │ └─ openapi.yml + └─ v2/ + ├─ generators.yml # Configures v2 SDKs + └─ openapi.yml ``` -Each API version must have its own `generators.yml` file that targets a [specific branch](/sdks/reference/generators-yml#github): - - - - -```yaml title="apis/v1/generators.yml" {11} -api: - specs: - - openapi: openapi.yml -groups: - ts-sdk: - generators: - - name: fernapi/fern-typescript-sdk - github: - repository: company/sdk - mode: push - branch: v1 # Targets v1 branch -``` - - +Each API must have its own `generators.yml` file: -```yaml title="apis/v2/generators.yml" {11} +```yaml title="apis/v1/generators.yml" api: specs: - openapi: openapi.yml @@ -175,12 +160,8 @@ groups: generators: - name: fernapi/fern-typescript-sdk github: - repository: company/sdk - mode: pull-request - branch: v2 # Targets v2 branch + repository: company/sdk-v1 ``` - - #### Option 2: Namespace-based versioning