Skip to content
Merged
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
17 changes: 12 additions & 5 deletions fern/products/docs/pages/api-references/sdk-snippets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ If you use Fern's SDK Generator, you can automatically show SDK code snippets in

## Configuring SDK Snippets

To configure SDK snippets, you'll need to name your SDKs in `generators.yml` and then reference that name in `docs.yml`. In the following example, We'll use `your-organization` as the package name because it is a common practice. For example, Stripe calls their npm package `stripe` and Twilio calls their PyPI package `twilio`.
To configure SDK snippets, you'll need to name your SDKs in `generators.yml` and then reference that name in `docs.yml`. In the following example, we'll use `your-organization` as the package name because it is a common practice. For example, Stripe calls their npm package `stripe` and Twilio calls their PyPI package `twilio`.

### Add examples to your API definition

In order to generate code snippets, Fern needs to read request examples from your API definition. If you're using a Fern Definition, you can follow [these instructions](/learn/api-definition/fern/examples). If you're using an OpenAPI Specification, you can follow [these instructions](https://swagger.io/docs/specification/adding-examples/).

### Define a package name for your SDK(s)

Configure package names in your `generators.yml` file:
* For **Python/TypeScript/Ruby**, add `package-name: your-package-name` to the `output` section.
* For **Go**, add `repository: your-organization/your-repository` to the `github` section.

<CodeBlock title="generators.yml">
```yaml
```yaml {9, 16, 22, 26}
groups:
production:
generators:
Expand Down Expand Up @@ -57,15 +61,18 @@ groups:
</Callout>

### Add the package name to your docs configuration
Add the package name for the corresponding SDK to your `docs.yml` file. For Go, use the exact URL where the SDK repository is located.
Add the package name for the corresponding SDK to your `docs.yml` file:
* **For Python, TypeScript, and Ruby**, `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/`.

<CodeBlock title="docs.yml">
```yaml
```yaml {4-7}
navigation:
- api: API Reference
snippets:
python: your-package-name # <--- needs to match the naming in generators.yml
typescript: your-package-name
typescript: your-package-name # <--- needs to match the naming in generators.yml
ruby: your-package-name # <--- needs to match the naming in generators.yml
go: https://github.com/your-organization/your-repository # <--- needs the https://github.com/ prefix
```
</CodeBlock>
Expand Down