Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions fern/products/docs/pages/api-references/sdk-snippets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ title: Display SDK snippets
description: Enable SDK code examples in TypeScript, Python, Go, and more from the request and response examples documented in your API definition. Once enabled, Fern Docs will automatically populate the snippets within your API Reference.
---

When you use Fern's SDK Generator, you can automatically display SDK code snippets in your API Reference. These snippets appear in a language selector dropdown, with cURL as the default option.
When you use Fern's SDK Generator, you can automatically display SDK code snippets in your API Reference. These snippets are generated from your API definition examples and appear in a language selector dropdown, with cURL as the default option.

<Note> Fern supports SDK snippets for TypeScript, Python, Ruby, Go, and .NET/C#. </Note>
<Note title="Dynamic snippets">
By default, SDK snippets are static code examples. Alternatively, you can use dynamic SDK snippets that allow users to modify parameters and see code examples update in real time.

To use dynamic snippets, [enable them in your `docs.yml`](/docs/configuration/what-is-docs-yml#dynamic-snippets-configuration) and then complete the setup instructions on this page.
</Note>

<Frame>
![SDK code snippet selector](https://fern-image-hosting.s3.amazonaws.com/sdk-code-snippets.png)
Expand All @@ -27,6 +31,8 @@ Configure package names in your `generators.yml` file:
* For **Python, TypeScript, Ruby, and .NET/C#**, add `package-name: your-package-name` to the `output` section.
* For **Go**, add `repository: your-organization/your-repository` to the `github` section.

<Note>Fern supports SDK snippets for TypeScript, Python, Ruby, Go, and .NET/C#. [Contact us](https://buildwithfern.com/contact) if you need support for more languages. </Note>

<CodeBlock title="generators.yml">
```yaml {9, 16, 22, 26}
groups:
Expand Down Expand Up @@ -71,6 +77,7 @@ groups:
</Callout>

### Add the package name to your docs configuration

Add the package name for the corresponding SDK to your `docs.yml` file:
* **For Python, TypeScript, Ruby, and .NET/C#**, `your-package-name` must match the `your-package-name` that you configured in your `generators.yml` file.
* **For Go**, use the exact URL where the SDK repository is located, including the `https://github.com/`.
Expand Down Expand Up @@ -110,7 +117,7 @@ navigation:

### Trigger generation

As the final step, trigger your docs generation by running `fern generate --docs` locally or in CI/CD (i.e., GitHub Actions). The SDK snippets will now appear via a drop-down!
As the final step, trigger your docs generation by running `fern generate --docs` locally or in CI/CD (i.e., GitHub Actions). The SDK snippets will now appear via a dropdown!

### Set default snippet language

Expand Down
13 changes: 13 additions & 0 deletions fern/products/docs/pages/customization/what-is-docs-yml.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -558,3 +558,16 @@ analytics:
<ParamField path="analytics.posthog.api-key" type="string" required={false}>
Your PostHog project API key. Defaults to the api-host of "https://us.i.posthog.com".
</ParamField>

## Dynamic snippets configuration

By default, SDK snippets are static code examples that are displayed in your API Reference. Alternatively, you can use dynamic SDK snippets that allow users to modify parameters and see code examples update in real time.

Enable dynamic snippets in `docs.yml`, then configure them by [following the SDK snippets setup instructions](/docs/api-references/sdk-snippets).

```yaml docs.yml
experimental:
dynamic-snippets: true
```


Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fern docs dev
A local preview of your documentation will be available at `http://localhost:3000`. The functionality is available offline if you have run local development mode online at least once.

<Note>
Some features (e.g. search) are disabled in the local development environment, including:
Some features are disabled in the local development environment, including:
- Search
- SEO (favicon, auto-generated meta tags, etc.)
- Authentication
Expand Down