### Java Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/changelog/2025-02-04.mdx
A simple 'Hello, world!' example in Java.
```java
System.out.println("Hello, world!");
```
--------------------------------
### Endpoint with Path Parameters and Examples
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints/rest.mdx
This example demonstrates defining a GET endpoint with a path parameter and providing a concrete example of a request and its expected response. The example includes path parameters and the response body.
```yml
service:
base-path: /users
auth: false
endpoints:
getUser:
path: /{userId}
path-parameters:
userId: string
method: GET
response: User
examples:
- path-parameters:
userId: alice-user-id
response:
body:
userId: alice-user-id
name: Alice
```
--------------------------------
### Python Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/changelog/2025-02-04.mdx
A simple 'Hello, world!' example in Python.
```python
print("Hello, world!");
```
--------------------------------
### Configure AI Examples Settings
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/navigation/site-level-settings.mdx
Enable and customize AI-generated examples for API Reference pages. This configuration allows setting a style guide for the generated examples, ensuring they align with brand or domain.
```yaml
ai-examples:
enabled: true # Enabled by default
style: "Use names and emails that are inspired by plants."
```
--------------------------------
### TypeScript Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/changelog/2025-02-04.mdx
A simple 'Hello, world!' example in TypeScript.
```typescript
console.log("Hello, world!");
```
--------------------------------
### Full Endpoint Example with Parameters
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints.mdx
An example showcasing path parameters, query parameters, headers, and response body.
```yaml
examples:
- path-parameters:
userId: some-user-id
query-parameters:
limit: 50
headers:
X-My-Header: some-value
response:
body:
response-field: hello
```
--------------------------------
### Link Target Configuration Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/changelog/2025-11-14.mdx
Example demonstrating how to configure the 'link target' property in navigation.
```yaml
navigation:
- title: "Docs"
url: "/docs"
link_target: "_blank"
```
--------------------------------
### Referencing Examples
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/examples.mdx
Shows how to reference an example from another type using the '$' syntax for composing examples.
```yaml
types:
UserId:
type: integer
examples:
- name: Example1
value: user-id-123
User:
properties:
id: UserId
name: string
examples:
- value:
id: $UserId.Example1
name: Jane Smith
```
--------------------------------
### Enrich OpenAPI with Examples (JSON Output)
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/pages/commands.mdx
Merges examples from an overrides file into native OpenAPI 'example' fields and outputs the result as JSON. Requires an overrides file and an output path.
```bash
fern api enrich openapi.yml -f overrides.yml -o enriched-openapi.json
```
--------------------------------
### Enrich OpenAPI with Examples (YAML Output)
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/pages/commands.mdx
Merges examples from an overrides file into native OpenAPI 'example' fields and outputs the result as YAML. Requires an overrides file and an output path.
```bash
fern api enrich openapi.yml -f overrides.yml -o enriched-openapi.yml
```
--------------------------------
### create Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints.mdx
Example of defining an endpoint to create a user with a POST request.
```APIDOC
## POST /users
### Description
Creates a new user.
### Method
POST
### Endpoint
/users
### Request Body
- **CreateUserRequest** - Required - The data for the new user.
```
--------------------------------
### Jinja Template Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/changelog/2024-06-25.mdx
Example of a Jinja template for rendering product information, demonstrating conditional logic and loops.
```html
Available Products
{% if products %}
{% else %}
No products are available at the moment.
{% endif %}
```
--------------------------------
### CreateShippingLabel Endpoint Examples with Headers
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/examples.mdx
Illustrates how to include global headers in the examples for the CreateShippingLabel endpoint.
```APIDOC
## POST /shipping
### Description
Create a new shipping label with global headers.
### Method
POST
### Endpoint
/shipping
### Headers
- **X-App-Id** (string) - Required
### Request Body
- **orderId** (string) - Required
- **weightInOunces** (integer) - Required
### Request Example
```json
{
"X-App-Id": "app_12345",
"orderId": "online_789",
"weightInOunces": 5
}
```
### Response
#### Success Response (200)
- **orderId** (string) - Description
- **weightInOunces** (integer) - Description
- **trackingNumber** (string) - Description
- **price** (double) - Description
#### Response Example
```json
{
"orderId": "online_789",
"weightInOunces": 5,
"trackingNumber": "1Z26W8370303469306",
"price": 2.50
}
```
### Errors
- **NotAuthorized** (401)
- **InsufficientFunds** (422)
```
--------------------------------
### OpenRPC Method with Examples
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/openrpc/extensions/examples.mdx
This YAML snippet shows how to define a user creation method in OpenRPC and include two distinct examples: a standard user and an admin user. Each example specifies request parameters and the expected response.
```yaml
methods:
- name: user.create
summary: Create a new user
params:
- name: userData
schema:
$ref: '#/components/schemas/CreateUserRequest'
required: true
x-fern-examples:
- name: StandardUser
description: Create a regular user account
params:
userData:
email: "john@example.com"
name: "John Doe"
role: "user"
result:
id: "user_123"
email: "john@example.com"
name: "John Doe"
role: "user"
createdAt: "2024-01-15T10:30:00Z"
- name: AdminUser
description: Create an admin user account
params:
userData:
email: "admin@example.com"
name: "Admin User"
role: "admin"
permissions: ["read", "write", "delete"]
result:
id: "user_456"
email: "admin@example.com"
name: "Admin User"
role: "admin"
createdAt: "2024-01-15T10:30:00Z"
result:
name: user
schema:
$ref: '#/components/schemas/User'
```
--------------------------------
### Referencing Type Example for Path Parameter
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints.mdx
Shows how to reference a type's example for a path parameter.
```yaml
service:
base-path: /users
auth: true
endpoints:
getUser:
method: GET
path: /{userId}
path-parameters:
userId: UserId
examples:
- path-parameters:
userId: $UserId.Example1
types:
UserId:
type: integer
examples:
- name: Example1
value: user-id-123
```
--------------------------------
### Example .fernignore File
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/custom-code.mdx
This is an example of a .fernignore file used to protect custom code and workflows from being overwritten during SDK regeneration.
```gitignore
# Documentation and licensing
README.md
LICENSE
# Custom workflows
.github/workflows/test.yml
.github/workflows/ci.yml
# Custom code
src/CustomClient.ts
```
--------------------------------
### Endpoint Example in user.yml
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints.mdx
Defines an example for the 'getUser' endpoint, including path parameters and response body.
```yaml
service:
base-path: /users
auth: false
endpoints:
getUser:
path: /{userId}
path-parameters:
userId: string
method: GET
response: User
errors:
- UserNotFoundError
examples:
- path-parameters:
userId: alice-user-id
response:
body:
userId: alice-user-id
name: Alice
types:
User:
properties:
userId: string
name: string
errors:
UserNotFoundError:
status-code: 404
```
--------------------------------
### Install Search Widget with yarn
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/ask-fern/search-widget.mdx
Install the search widget package along with React dependencies using yarn.
```bash
yarn add @fern-api/search-widget react@19 react-dom@19
```
--------------------------------
### Install aiohttp Extra with Poetry
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/python/aiohttp-support.mdx
Users can opt into aiohttp support by installing the package with the `aiohttp` extra using Poetry.
```bash
poetry add "your-package[aiohttp]"
```
--------------------------------
### Install Search Widget with npm
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/ask-fern/search-widget.mdx
Install the search widget package along with React dependencies using npm.
```bash
npm install @fern-api/search-widget react@19 react-dom@19
```
--------------------------------
### getAllUsers Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints.mdx
Example of defining an endpoint to retrieve all users with a GET request and a limit query parameter.
```APIDOC
## GET /users/all
### Description
Retrieves a list of all users. Supports pagination via a `limit` query parameter.
### Method
GET
### Endpoint
/users/all
### Parameters
#### Query Parameters
- **limit** (optional) - The maximum number of users to return.
```
--------------------------------
### Initialize Fern project with documentation
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/pages/commands.mdx
Initializes a new Fern project and includes a sample documentation website with an API Reference section.
```bash
fern init --docs
```
--------------------------------
### Using the Generated Go Client
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/go/changelog/2025-01-22.mdx
Demonstrates how to instantiate and use the generated Go client with the new configuration.
```go
package main
import (
"context"
"fmt"
"log"
acme "github.com/acme/acme-go"
)
func main() {
client := acme.New()
response, err := client.GetUser(
context.Background(),
&acme.GetUserRequest{
ID: "85307b0b-094b-41b5-b61d-347ca15e5da2",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(response)
}
```
--------------------------------
### Get Slack Install Link via cURL
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/ask-fern/slack-app.mdx
Use this cURL request to obtain a unique Slack installation link for your organization. Ensure you replace placeholders with your actual Fern token and domain.
```bash
curl -G https://fai.buildwithfern.com/slack/get-install \
-H "Authorization: Bearer " \
--data-urlencode domain=
```
--------------------------------
### Example YAML Configuration for Link Construction
Source: https://github.com/fern-api/docs/blob/main/AGENTS.md
Illustrates a sample YAML configuration for a product and its section, demonstrating how these structures translate into a correct internal URL.
```yaml
```yaml
- display-name: Docs
path: ./products/docs/docs.yml
slug: docs
```
And `fern/products/docs/docs.yml`:
```yaml
- section: Getting started
contents:
- page: Overview
path: ./pages/getting-started/overview.mdx
```
```
--------------------------------
### Get Fern Writer Install Link via cURL
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/ai/writer.mdx
Use this cURL request to obtain a unique Slack installation link for Fern Writer. You need your Fern token and the GitHub repository in owner/repo format. The Fern GitHub App must be installed in the repository.
```bash
curl -G https://fai.buildwithfern.com/scribe/slack/get-install \
-H "Authorization: Bearer " \
--data-urlencode github_repo=
```
--------------------------------
### NPM Publishing Workflow Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/typescript/publishing-to-npm.mdx
This is an example of a GitHub Actions workflow file that handles the publishing of your NPM package. It includes steps for checking out the code, setting up Node.js, installing dependencies, and publishing to NPM.
```yaml
.github/workflows/ci.yml
```yaml
name: CI
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```
```
--------------------------------
### Go SDK Configuration
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/go/changelog/2025-01-22.mdx
Example of configuring the Go SDK with new options like packageLayout and clientName.
```yaml
---
name: fern-api/fern-go-sdk
version: 0.36.0
config:
packageLayout: flat
clientName: Acme
clientConstructorName: New
```
--------------------------------
### Endpoint with Code Sample
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/openapi/extensions/examples.mdx
Associates a TypeScript SDK code sample with an example for a GET request, demonstrating how to use the generated client.
```yaml
paths:
/users/{userId}:
get:
x-fern-examples:
- path-parameters:
userId: user-1234
response:
body:
name: Foo
ssn: 1234
code-samples:
- sdk: typescript
code: |
import { UserClient } from "...";
client.users.get("user-1234")
```
--------------------------------
### Custom Synchronization Group: yarn Install
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/component-library/default-components/code-blocks.mdx
Example of a custom synchronization group using the 'for' prop to group by package manager (yarn).
```bash
yarn add plantstore
```
--------------------------------
### Initialize SDK from Web-Hosted AsyncAPI File
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/snippets/option-3-asyncapi.mdx
Use this command to initialize a Fern project from an AsyncAPI specification hosted on a web URL. Replace `https://api.example.com/asyncapi.yml` with the URL of your specification and `` with your organization's name.
```bash
fern init --asyncapi https://api.example.com/asyncapi.yml --organization
```
--------------------------------
### Custom Synchronization Group: pnpm Install
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/component-library/default-components/code-blocks.mdx
Example of a custom synchronization group using the 'for' prop to group by package manager (pnpm).
```bash
pnpm add plantstore
```
--------------------------------
### C# SDK Setup (GitHub Repositories)
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/csharp/quickstart.mdx
This snippet, intended for C# SDK setup, likely involves configuring GitHub repositories for version control and automated workflows. Refer to the full documentation for specific implementation details.
```csharp
```
--------------------------------
### Custom Synchronization Group: npm Install
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/component-library/default-components/code-blocks.mdx
Example of a custom synchronization group using the 'for' prop to group by package manager (npm).
```bash
npm install plantstore
```
--------------------------------
### Preview All SDKs
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/pages/commands.mdx
Test local SDK changes before publishing by generating SDKs into a local .preview/ folder.
```bash
fern generate --preview
```
--------------------------------
### Initialize Fern with Petstore Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/snippets/init-fern-folder.mdx
Initializes the Fern folder using the Petstore OpenAPI specification from a URL and sets the organization name to 'my-org'.
```bash
fern init --openapi https://petstore3.swagger.io/api/v3/openapi.json \
--organization my-org
```
--------------------------------
### Fern Project Setup: generators.yml
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/asyncapi/overview.mdx
Configuration file for Fern generators, defining the API specifications to be used. This example points to an AsyncAPI specification file.
```yaml
# Your API definition
api:
specs:
- asyncapi: ./asyncapi/asyncapi.yml
groups:
external:
generators:
# Your generator configurations here
```
--------------------------------
### Endpoint with Path Parameters and Headers
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/openapi/extensions/examples.mdx
Defines an example for a GET request to an endpoint with a path parameter and custom headers. Headers declared with `x-fern-global-headers` must be included.
```yaml
paths:
/users/{userId}:
get:
x-fern-examples:
- name: Get user 1234 # Optional descriptive label
headers:
custom_api_key: "capi_12345" # header defined using x-global-header extension
userpool_id: "pool_67890" # header defined using x-global-header extension
path-parameters:
userId: user-1234
response:
body:
name: Foo
ssn: 1234
```
--------------------------------
### Fern Project Setup: fern.config.json
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/asyncapi/overview.mdx
Configuration file for Fern CLI, specifying the organization and CLI version. Ensure the version matches your installed Fern CLI.
```json
{
"organization": "your-organization",
"version": ""
}
```
--------------------------------
### Setup GitHub Repositories for SDK
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/typescript/quickstart.mdx
This snippet, written in TypeScript, outlines the process for setting up GitHub repositories for your generated SDK. It's a prerequisite for automated publishing.
```typescript
import { GitHub } from "@fern-api/github";
const github = new GitHub({
token: process.env.GITHUB_TOKEN,
});
await github.createRepository({
name: "my-awesome-sdk",
// ... other options
});
```
--------------------------------
### Defining Endpoint Error Responses
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/endpoints.mdx
Specify custom error responses for an endpoint, detailing non-200 status codes that might be returned. This example defines a 'UserNotFoundError' for a GET request.
```yaml
service:
base-path: /users
auth: false
endpoints:
getUser:
path: "/{userId}"
path-parameters:
userId: string
method: GET
response: User
errors:
- UserNotFoundError
types:
User:
properties:
userId: string
name: string
errors:
UserNotFoundError:
status-code: 404
```
--------------------------------
### Internal Link Example in MDX
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/component-library/writing-content/markdown-basics.mdx
Create internal links to other pages or specific headings on your Fern documentation site using published site paths. Ensure paths start with '/'.
```mdx
Learn about [how Fern SDKs work](/learn/sdks/overview/how-it-works).
Configure [sidebar icons](/learn/docs/configuration/navigation#sidebar-icons) to add visual cues to your navigation.
```
--------------------------------
### Go SDK File Structure Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/go/quickstart.mdx
This illustrates the typical file and folder structure created after generating a Go SDK. It includes core files and the go.mod file.
```text
fern/
# created by fern init
sdks/
# created by fern generate --group go-sdk
go/
core/
go.mod
```
--------------------------------
### Example Output of Publishing Docs
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/preview-publish/publishing-your-docs.mdx
This example shows the expected output after successfully publishing your docs, including checks passed and the production URL.
```bash
fern generate --docs
[docs]: Found 0 errors and 1 warnings. Run fern check --warnings to print out the warnings.
[docs]: ✓ All checks passed
[docs]: Published docs to https://plantstore.docs.buildwithfern.com
┌─
│ ✓ https://plantstore.docs.buildwithfern.com
└─
```
--------------------------------
### Prompt Component Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/changelog/2026-04-27.mdx
Displays an AI prompt card with a title, icon, copy button, and optional 'Open in' actions. Use this component in tutorials or guides where users need to interact with AI assistants.
```jsx
You are a **docs setup assistant**. Help the user create and publish a new docs site.
Follow the [Quickstart guide](https://buildwithfern.com/learn/docs/getting-started/quickstart) step by step.
```
--------------------------------
### Readiness Probe
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/self-hosted/health-check-endpoints.mdx
The readiness probe (`GET /readiness`) verifies that all services are healthy and ready to serve traffic. It returns success only when all services are fully initialized and responsive, preventing traffic routing to containers that are still starting up.
```APIDOC
## GET /readiness
### Description
Verifies that all services are healthy and ready to serve traffic by testing their health endpoints. It returns success only when all services are fully initialized and responsive.
### Method
GET
### Endpoint
/readiness
### Parameters
#### Query Parameters
None
### Request Example
```bash
curl http://localhost:8081/readiness
```
### Response
#### Success Response (200 OK)
All services are ready to serve traffic.
#### Error Response (503 Service Unavailable)
One or more services aren't ready (wait longer).
#### Checked services
- PostgreSQL (via `pg_isready`)
- MinIO (via `/minio/health/live`)
- FDR server (via `/health`)
- Next.js docs server (via root endpoint)
- MeiliSearch (warning only, non-critical)
```
--------------------------------
### Example docs.yml with Landing Page
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/navigation/products.mdx
Configures a site-level landing page independent of products, accessible at the root URL or a specified slug.
```yaml
landing-page:
page: Welcome
path: ./pages/welcome.mdx
slug: /welcome # optional
products:
- display-name: Product A
path: ./products/product-a.yml
- display-name: Product B
path: ./products/product-b.yml
```
--------------------------------
### Setup GitHub Repositories for Rust SDK
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/rust/quickstart.mdx
This section outlines the steps for setting up GitHub repositories, which is a prerequisite for publishing your Rust SDK.
```rust
# In your root directory, run:
fern github-repo add fern-rust-sdk --group rust-sdk
# This will create a new GitHub repository for your Rust SDK and add it to your generators.yml:
# generators.yml
rust-sdk:
# ... other config
github:
repo-url: https://github.com/your-org/fern-rust-sdk
publish-via: github-actions
```
--------------------------------
### OpenAPI $ref Sibling Examples
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/cli-changelog/2025-12-15.mdx
Demonstrates how OpenAPI 3.1+ allows sibling `example`/`examples` properties to take precedence over `$ref` examples.
```yaml
# OpenAPI 3.1+ allows $ref siblings like example/examples
Company:
type: object
properties:
logo:
$ref: '#/components/schemas/File'
example:
url: https://images.example.com/logo.png # This example is now used
```
--------------------------------
### Run self-hosted documentation with custom domain
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/self-hosted/self-hosted-set-up.mdx
Start the self-hosted documentation container, overriding the custom domain at runtime using the `CUSTOM_DOMAIN` environment variable.
```bash
docker run -p 3000:3000 -e CUSTOM_DOMAIN=docs.plantstore.dev self-hosted-docs
```
--------------------------------
### Referencing a Specific Example from OpenAPI Spec
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/component-library/default-components/endpoint-response-snippet.mdx
To reference a particular example defined in your OpenAPI specification, provide both the endpoint and the example name. This is useful when you have multiple examples for a single endpoint.
```yaml
paths:
/pet/{petId}:
put:
summary: Get a pet
operationId: pets_get
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
examples:
ExampleWithMarkley:
summary: This is an example of a Pet
value:
name: Markley
id: 44
```
```jsx
```
--------------------------------
### Run the self-hosted documentation container
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/self-hosted/self-hosted-set-up.mdx
Start a Docker container from the `self-hosted-docs` image and map port 3000 from the container to the host.
```bash
docker run -p 3000:3000 self-hosted-docs
```
--------------------------------
### Install Fern CLI
Source: https://github.com/fern-api/docs/blob/main/README.md
Installs the Fern CLI globally using npm. Ensure Node.js and npm are installed and up to date.
```bash
npm install -g fern-api
```
--------------------------------
### Start Local Fern Docs Preview Server
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/preview-publish/preview-changes-locally.mdx
Run this command from the directory containing your fern folder to start a local preview server. You can also specify a custom port.
```bash
# Start preview server (from directory containing fern folder)
fern docs dev
# Or use a custom port
fern docs dev --port 3002
```
--------------------------------
### Java SDK Client Initialization
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/deep-dives/server-url-templating.mdx
Demonstrates how to initialize a Java SDK client using the default environment, specific regional/environmental variables, or a custom base URL.
```java
import com.example.api.MyApiClient;
// Use the default environment
// → https://api.example.com/v1
MyApiClient client = MyApiClient.builder().build();
// Target a specific region and environment via URL variables
// → https://api.eu-west-1.staging.example.com/v1
MyApiClient client = MyApiClient.builder()
.region("eu-west-1")
.serverUrlEnvironment("staging")
.build();
// Or provide a custom base URL
// → https://api.us-west-2.staging.example.com/v1
MyApiClient client = MyApiClient.builder()
.url("https://api.us-west-2.staging.example.com/v1")
.build();
```
--------------------------------
### Conditional Inclusion of Examples in JSDoc
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/generators/typescript/changelog/2024-04-30.mdx
Shows how the generator includes user-provided examples only if they exist, otherwise defaulting to a single generated example.
```typescript
/**
* This endpoint checks the health of a resource.
*
* @example
* await testSdk.health.service.check("id-2sdx82h")
*/
public async check(id: string, requestOptions?: Service.RequestOptions): Promise {
...
}
```
--------------------------------
### CreateShippingLabel Endpoint Examples
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/examples.mdx
Demonstrates how to provide examples for the CreateShippingLabel endpoint, including direct request/response bodies, referencing other examples, and handling errors.
```APIDOC
## POST /shipping
### Description
Create a new shipping label.
### Method
POST
### Endpoint
/shipping
### Request Body
- **orderId** (string) - Required
- **weightInOunces** (integer) - Required
### Request Example
```json
{
"orderId": "online_789",
"weightInOunces": 5
}
```
### Response
#### Success Response (200)
- **orderId** (string) - Description
- **weightInOunces** (integer) - Description
- **trackingNumber** (string) - Description
- **price** (double) - Description
#### Response Example
```json
{
"orderId": "online_789",
"weightInOunces": 5,
"trackingNumber": "1Z26W8370303469306",
"price": 2.50
}
```
### Errors
- **NotAuthorized** (401)
- **InsufficientFunds** (422)
```
--------------------------------
### Initialize Fern project with Mintlify configuration
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/pages/commands.mdx
Initializes a new Fern project by converting an existing Mintlify docs folder, using the provided path to the Mintlify configuration.
```bash
fern init --mintlify PATH_TO_MINT_CONFIG
```
--------------------------------
### Define Endpoint Examples
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/ferndef/examples.mdx
Examples for a service endpoint, including request, response, and error scenarios. Demonstrates direct values and referencing other examples.
```yml
service:
auth: true
base-path: ""
endpoints:
CreateShippingLabel:
docs: Create a new shipping label.
method: POST
path: /shipping
request: CreateShippingLabelRequest
response: ShippingLabel
errors:
- NotAuthorized
- InsufficientFunds
examples:
# A successful response that doesn't reference other examples.
- request:
orderId: "online_789"
weightInOunces: 5
response:
body:
orderId: "online_789"
weightInOunces: 5
trackingNumber: "1Z26W8370303469306"
price: 2.50
# A successful response that uses references.
- request: $CreateShippingLabelRequest.SuccessfulRequest
response:
body: $ShippingLabel.Default
# An error response.
- request: $CreateShippingLabelRequest.InsufficientFundsRequest
response:
error: InsufficientFunds
body: $InsufficientFundsBody.Default
types:
CreateShippingLabelRequest:
properties:
orderId: string
weightInOunces: integer
examples:
- name: SuccessfulRequest
value:
orderId: "online_123"
weightInOunces: 13
- name: InsufficientFundsRequest
value:
orderId: "online_456"
weightInOunces: 2000
ShippingLabel:
properties:
orderId: string
weightInOunces: integer
trackingNumber: string
price: double
examples:
- name: Default
value:
orderId: "online_123"
weightInOunces: 13
trackingNumber: "1Z12345E0205271688"
price: 12.35
InsufficientFundsBody:
properties:
message: string
examples:
- name: Default
value:
message: "Insufficient funds to create shipping label."
errors:
NotAuthorized:
status-code: 401
InsufficientFunds:
status-code: 422
type: InsufficientFundsBody
```
--------------------------------
### Sample docs.yaml configuration
Source: https://github.com/fern-api/docs/blob/main/fern/products/cli-api-reference/pages/commands.mdx
Example configuration for `docs.yaml` when initializing a Fern project with the `--docs` flag.
```yaml
instances:
- url: https://your-organization.docs.buildwithfern.com
title: Your Organization | Documentation
navigation:
- api: API Reference
colors:
accent-primary: '#ffffff'
background: '#000000'
```
--------------------------------
### Initialize SDK from Local AsyncAPI File
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/snippets/option-3-asyncapi.mdx
Use this command to initialize a Fern project from a local AsyncAPI specification file. Ensure you replace `path/to/asyncapi.yml` with the actual path to your file and `` with your organization's name.
```bash
fern init --asyncapi path/to/asyncapi.yml --organization
```
--------------------------------
### Complete Feature Flag Configuration Example
Source: https://github.com/fern-api/docs/blob/main/fern/products/docs/pages/integrations/feature-flags.mdx
An example of a complete `docs.yml` configuration demonstrating nested feature flags for navigation sections and pages.
```yaml
# docs.yml
title: API Documentation
navigation:
- section: Features
feature-flag: features-enabled
layout:
- page: Basic Features
- page: Advanced Features
feature-flag: advanced-features
- page: Beta Features
feature:
- flag: beta-access
- flag: beta-opted-in
- section: Enterprise
feature-flag:
flag: customer-tier
match: enterprise
fallbackValue: standard
```
--------------------------------
### Python SDK Client Initialization
Source: https://github.com/fern-api/docs/blob/main/fern/products/sdks/deep-dives/server-url-templating.mdx
Demonstrates how to initialize a Python SDK client using the default environment, specific regional/environmental variables, or a custom base URL.
```python
from my_api import MyApiClient
# Use the default environment
# → https://api.example.com/v1
client = MyApiClient()
# Target a specific region and environment via URL variables
# → https://api.eu-west-1.staging.example.com/v1
client = MyApiClient(
region="eu-west-1",
environment="staging",
)
# Or provide a custom base URL
# → https://api.us-west-2.staging.example.com/v1
client = MyApiClient(
base_url="https://api.us-west-2.staging.example.com/v1",
)
```
--------------------------------
### Provide Examples for HTTP JSON Endpoints
Source: https://github.com/fern-api/docs/blob/main/fern/products/api-def/openapi/endpoints/rest.mdx
Adds examples for request and response bodies to an existing endpoint definition. Use the `examples` key to provide sample data.
```yaml
paths:
/pets:
post:
summary: Create a new pet
description: Creates a new pet with the provided information
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
examples:
PetExample:
summary: This is an example of a Pet
value:
name: Markley
id: 44
responses:
'200':
description: A Pet object
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
examples:
PetExample:
summary: This is an example of a Pet
value:
name: Markley
id: 44
```