Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions fern/apis/generators-yml/definition/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,22 @@ types:
- v1
- v2

OverridesSchema:
discriminated: false
docs: Paths to the overrides configuration. Can be a single path or an array of paths applied sequentially.
union:
- string
- list<string>

APIDefinitionWithOverridesSchema:
properties:
path: APIDefinitionPathSchema
origin:
type: optional<string>
docs: The URL of the API definition origin, from which the file should be polled.
overrides:
type: optional<string>
docs: Path to the OpenAPI or AsyncAPI overrides
type: optional<OverridesSchema>
docs: Paths to the overrides configuration. Can be a single path or an array of paths applied sequentially.
audiences:
type: optional<list<string>>
docs: Audiences that you would like to filter to
Expand All @@ -190,8 +197,8 @@ types:
type: string
docs: The path to the `.proto` directory root (e.g. `proto`).
overrides:
type: optional<string>
docs: Path to the overrides configuration
type: optional<OverridesSchema>
docs: Paths to the overrides configuration. Can be a single path or an array of paths applied sequentially.
local-generation:
type: optional<boolean>
docs: Whether to compile the `.proto` files locally. By default, we generate remotely.
Expand Down Expand Up @@ -324,14 +331,14 @@ types:
properties:
openapi: string
origin: optional<string>
overrides: optional<string>
overrides: optional<OverridesSchema>
namespace: optional<string>
settings: optional<OpenAPISettingsSchema>

OpenRPCSpecSchema:
properties:
openrpc: string
overrides: optional<string>
overrides: optional<OverridesSchema>
namespace: optional<string>

AsyncAPISettingsSchema:
Expand All @@ -346,7 +353,7 @@ types:
properties:
asyncapi: string
origin: optional<string>
overrides: optional<string>
overrides: optional<OverridesSchema>
namespace: optional<string>
settings: optional<AsyncAPISettingsSchema>

Expand All @@ -367,4 +374,4 @@ types:

ProtobufSpecSchema:
properties:
proto: ProtobufDefinitionSchema
proto: ProtobufDefinitionSchema
30 changes: 30 additions & 0 deletions fern/products/api-def/pages/overrides.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ api:
- openapi: spec-file.yml
overrides: ./overrides.yml
```

You can also specify multiple override files. When multiple paths are provided, overrides are applied sequentially in the order listed:

```yaml title="generators.yml"
api:
specs:
- openapi: spec-file.yml
overrides:
- ./base-overrides.yml
- ./sdk-overrides.yml
```
</Step>
<Step title="Fern combines your spec and overrides">
Now when you run `fern generate`, Fern combines your original API specification with the overrides file:
Expand Down Expand Up @@ -100,6 +111,25 @@ paths:
</Step>
</Steps>

## Multiple override files

The `overrides` field accepts a single path or a list of paths. When multiple paths are provided, overrides are applied sequentially in order, with later files taking precedence over earlier ones for conflicting keys. This is useful for:

* Separating vendor-specific SDK customizations from shared API overrides
* Layering team-specific overrides on top of base configurations
* Keeping override files small and focused on specific concerns

```yaml title="generators.yml"
api:
specs:
- openapi: openapi.yml
overrides:
- ./base-overrides.yml # Shared overrides (e.g., SDK method names)
- ./team-overrides.yml # Team-specific customizations
```

Multiple override files are supported for all spec types: OpenAPI, AsyncAPI, OpenRPC, and Protobuf.

## Separate overrides for SDKs and docs

<Markdown src="/snippets/separate-sdks-docs.mdx" type="overrides" />
Expand Down
30 changes: 25 additions & 5 deletions fern/products/sdks/reference/generators-yml-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ api:
specs:
- asyncapi: "./asyncapi.yml"
origin: "https://api.example.com/asyncapi.json"
overrides: "./asyncapi-overrides.yml"
overrides: "./asyncapi-overrides.yml" # or a list of paths
namespace: "events"
settings:
message-naming: "v2"
Expand All @@ -237,8 +237,18 @@ api:
URL of the API definition origin for pulling updates.
</ParamField>

<ParamField path="overrides" type="string" toc={true}>
Path to AsyncAPI overrides file.
<ParamField path="overrides" type="string | list of strings" toc={true}>
Path to an AsyncAPI [overrides](/learn/api-definitions/overview/overrides) file, or a list of paths to multiple override files applied sequentially.

```yaml
# Single override file
overrides: ./asyncapi-overrides.yml

# Multiple override files (applied in order)
overrides:
- ./base-overrides.yml
- ./sdk-overrides.yml
```
</ParamField>

<ParamField path="namespace" type="string" toc={true}>
Expand Down Expand Up @@ -287,8 +297,18 @@ api:
Path to the OpenRPC specification file.
</ParamField>

<ParamField path="overrides" type="string" toc={true}>
Path to OpenRPC overrides file.
<ParamField path="overrides" type="string | list of strings" toc={true}>
Path to an OpenRPC [overrides](/learn/api-definitions/overview/overrides) file, or a list of paths to multiple override files applied sequentially.

```yaml
# Single override file
overrides: ./overrides.yml

# Multiple override files (applied in order)
overrides:
- ./base-overrides.yml
- ./sdk-overrides.yml
```
</ParamField>

<ParamField path="namespace" type="string" toc={true}>
Expand Down
14 changes: 12 additions & 2 deletions fern/snippets/grpc-specs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ api:
Path to the target `.proto` file (e.g., `proto/user/v1/user.proto`). Omit to generate docs for the entire root folder.
</ParamField>

<ParamField path="overrides" type="string" toc={true}>
Path to the overrides configuration file. Used for SDK generation only, not for documentation generation.
<ParamField path="overrides" type="string | list of strings" toc={true}>
Path to the overrides configuration file, or a list of paths to multiple override files applied sequentially. Used for SDK generation only, not for documentation generation.

```yaml
# Single override file
overrides: ./overrides.yml

# Multiple override files (applied in order)
overrides:
- ./base-overrides.yml
- ./sdk-overrides.yml
```
</ParamField>

<ParamField path="local-generation" type="boolean" default="false" toc={true}>
Expand Down
16 changes: 13 additions & 3 deletions fern/snippets/openapi-specs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ api:
- openapi: "./openapi.yml"
origin: "https://api.example.com/openapi.json"
overlays: "./openapi-overlays.yml"
overrides: "./openapi-overrides.yml"
overrides: "./openapi-overrides.yml" # or a list of paths
namespace: "v1"
settings:
title-as-schema-name: true
Expand All @@ -30,8 +30,18 @@ api:
Path to an [OpenAPI Overlay](/learn/api-definitions/openapi/overlays) file. Overlays follow the [OpenAPI Overlay Specification](https://spec.openapis.org/overlay/v1.0.0.html) and are the recommended approach for customizing OpenAPI specifications.
</ParamField>

<ParamField path="overrides" type="string" toc={true}>
Path to OpenAPI overrides file. Consider using `overlays` instead for a standards-based approach.
<ParamField path="overrides" type="string | list of strings" toc={true}>
Path to an OpenAPI [overrides](/learn/api-definitions/overview/overrides) file, or a list of paths to multiple override files applied sequentially. Consider using `overlays` instead for a standards-based approach.

```yaml
# Single override file
overrides: ./overrides.yml

# Multiple override files (applied in order)
overrides:
- ./base-overrides.yml
- ./sdk-overrides.yml
```
</ParamField>

<ParamField path="namespace" type="string" toc={true}>
Expand Down
Loading