Request + response examples
Request + response examples
Request + response examples
Fern generates realistic examples automatically using AI-generated examples, enabled by default. Use x-fern-examples to manually define specific example values. Manual examples take priority over AI-generated ones. You can also disable AI examples entirely.
Use x-fern-examples to associate specific request and response pairs or define multiple named examples for an endpoint. OpenAPI has several example fields, but provides no way to link a request with its corresponding response.
x-fern-examples is an array. Each element can contain path-parameters, query-parameters, headers, request, and response values that are all associated. Optionally, add a name field to provide a descriptive label.
request holds the request body properties directly.response requires a nested body key containing the response body properties.Examples must include any headers declared with the x-fern-global-headers extension. Place them under headers alongside path-parameters and request.
An endpoint with path parameters:
An endpoint with a request body:
Fern generators automatically add SDK code samples. To specify custom code samples for an example, use code-samples.
To make x-fern-examples work with non-Fern OpenAPI tools, run fern api enrich to convert them into native OpenAPI example fields.