Overlays
Overlays let you customize your OpenAPI specification without modifying the original file. This is useful when:
- Your API specification is auto-generated from server code
- You need different configurations for SDKs versus documentation
- You want to add Fern configurations like pagination or SDK method names
- You want to make bulk changes across many endpoints using JSONPath wildcards
Overlays follow the OpenAPI Overlay Specification and are portable across the OpenAPI ecosystem.
Fern recommends using overlays instead of overrides for OpenAPI specs.
Overrides are also fully supported. If overrides are working for your team, there’s no need to switch. You can also use both together (overrides are applied first, then overlays).
Configure overlays
To use overlays, create an overlays file in the same folder as your spec and reference it in generators.yml:
Define the overlays file
Each action in an overlay targets elements using JSONPath and applies an update or remove operation:
Fern requires parentheses around JSONPath filter expressions. Use [?(@.name == 'plantId')] instead of [?@.name == 'plantId'].
Modifying OpenAPI properties
Use update to change standard OpenAPI properties like descriptions, summaries, or other fields:
Customizing with Fern extensions
Use update to add Fern extensions:
Removing elements
Use remove: true to delete elements from your specification:
Separate overlays for SDKs and docs
Use different overlays files for SDK generation versus documentation by creating separate folders with their own generators.yml:
Overlays for different environments
Configure different overlays for production versus internal APIs: