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
Overlays follow the OpenAPI Overlay Specification.
Fern recommends using OpenAPI overlays instead of overrides for OpenAPI specs. Overlays follow the official OpenAPI Overlay Specification and are portable across different tools.
Overrides are also fully supported. If your team already uses overrides, there’s no need to switch unless you need advanced functionality. 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: