Examples in Fern Definition
Use Fern Definition to add API examples that are shown in comments of SDKs, API Reference documentation, and a Postman collection.
You can add examples for types and endpoints. Examples are shown as comments in your SDKs, in the request & response of your documentation, and in a Postman Collection.
Validation
The Fern CLI validates that your examples match the expected types. The following won’t compile:
CLI Error Message
Referencing examples
You can reference an example from another type, endpoint, or error.
Just like types, you can compose examples. To reference an example from another
type, use $
.
Examples for types
Objects
Generated TypeScript SDK
Lists
Unions
Discriminated union
Generated TypeScript SDK
Undiscriminated union
Generated TypeScript SDK
Aliases
Generated TypeScript SDK
Examples for endpoints
You can add examples of successful and error responses for your endpoints. Examples can reference the examples of types to avoid duplication.