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.
Overlays are the recommended approach for customizing OpenAPI specifications. Compared to overrides, overlays offer additional capabilities like bulk modifications using JSONPath wildcards and the ability to modify elements within arrays.
Fern still supports overrides for backward compatibility.
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: