You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/docs/pages/api-references/sdk-snippets.mdx
+12-5Lines changed: 12 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,16 +11,20 @@ If you use Fern's SDK Generator, you can automatically show SDK code snippets in
11
11
12
12
## Configuring SDK Snippets
13
13
14
-
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`.
14
+
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`.
15
15
16
16
### Add examples to your API definition
17
17
18
18
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/).
19
19
20
20
### Define a package name for your SDK(s)
21
21
22
+
Configure package names in your `generators.yml` file:
23
+
* For **Python/TypeScript/Ruby**, add `package-name: your-package-name` to the `output` section.
24
+
* For **Go**, add `repository: your-organization/your-repository` to the `github` section.
25
+
22
26
<CodeBlocktitle="generators.yml">
23
-
```yaml
27
+
```yaml {9, 16, 22, 26}
24
28
groups:
25
29
production:
26
30
generators:
@@ -57,15 +61,18 @@ groups:
57
61
</Callout>
58
62
59
63
### Add the package name to your docs configuration
60
-
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.
64
+
Add the package name for the corresponding SDK to your `docs.yml` file:
65
+
***For Python, TypeScript, and Ruby**, `your-package-name` must match the `your-package-name` that you configured in your `generators.yml` file.
66
+
***For Go**, use the exact URL where the SDK repository is located, including the `https://github.com/`.
61
67
62
68
<CodeBlocktitle="docs.yml">
63
-
```yaml
69
+
```yaml{4-7}
64
70
navigation:
65
71
- api: API Reference
66
72
snippets:
67
73
python: your-package-name # <--- needs to match the naming in generators.yml
68
-
typescript: your-package-name
74
+
typescript: your-package-name # <--- needs to match the naming in generators.yml
75
+
ruby: your-package-name # <--- needs to match the naming in generators.yml
69
76
go: https://github.com/your-organization/your-repository # <--- needs the https://github.com/ prefix
0 commit comments