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
+21-19Lines changed: 21 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,19 @@ title: Display SDK snippets
3
3
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.
4
4
---
5
5
6
-
If you use Fern's SDK Generator, you can automatically show SDK code snippets in your API Reference. SDK languages appear in a drop-down. By default, cURL snippets will be displayed to users.
6
+
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.
7
+
8
+
<Note> Fern supports SDK snippets for TypeScript, Python, Ruby, Go, and .NET/C#. </Note>
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`.
16
+
To configure SDK snippets, you'll need to name your SDKs in `generators.yml` and then reference that name in `docs.yml`.
17
+
18
+
<Steps>
15
19
16
20
### Add examples to your API definition
17
21
@@ -20,7 +24,7 @@ In order to generate code snippets, Fern needs to read request examples from you
20
24
### Define a package name for your SDK(s)
21
25
22
26
Configure package names in your `generators.yml` file:
23
-
* For **Python/TypeScript/Ruby**, add `package-name: your-package-name` to the `output` section.
27
+
* For **Python, TypeScript, Ruby, and .NET/C#**, add `package-name: your-package-name` to the `output` section.
24
28
* For **Go**, add `repository: your-organization/your-repository` to the `github` section.
repository: your-organization/your-repository # <--- add this field
54
64
...
@@ -62,7 +72,7 @@ groups:
62
72
63
73
### Add the package name to your docs configuration
64
74
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.
75
+
***For Python, TypeScript, Ruby, and .NET/C#**, `your-package-name` must match the `your-package-name` that you configured in your `generators.yml` file.
66
76
***For Go**, use the exact URL where the SDK repository is located, including the `https://github.com/`.
67
77
68
78
<CodeBlocktitle="docs.yml">
@@ -73,6 +83,7 @@ navigation:
73
83
python: your-package-name # <--- needs to match the naming in generators.yml
74
84
typescript: your-package-name # <--- needs to match the naming in generators.yml
75
85
ruby: your-package-name # <--- needs to match the naming in generators.yml
86
+
csharp: your-package-name # <--- needs to match the naming in generators.yml
76
87
go: https://github.com/your-organization/your-repository # <--- needs the https://github.com/ prefix
77
88
```
78
89
</CodeBlock>
@@ -87,17 +98,6 @@ As the final step, trigger your docs generation by running `fern generate --docs
87
98
88
99
### Set default snippet language
89
100
90
-
SDK code snippets support several languages. Our development work is driven by customer requests, so please request support for languages not listed here by [opening an issue](https://github.com/fern-api/fern/issues/new/choose).
91
-
92
-
* csharp
93
-
* curl
94
-
* go
95
-
* java
96
-
* javascript
97
-
* python
98
-
* ruby
99
-
* typescript
100
-
101
101
To set the default snippet language, use the `default-language` key at the top indentation level of `docs.yml`.
102
102
103
103
<CodeBlock title="docs.yml">
@@ -112,6 +112,8 @@ navigation:
112
112
```
113
113
</CodeBlock>
114
114
115
+
</Steps>
116
+
115
117
## Access via API
116
118
117
119
If you'd like to bring SDK snippets into your own documentation, you can use the [Snippets API](/learn/api-reference/snippets/get). API access requires a [SDK Business plan](https://buildwithfern.com/pricing) or above.
0 commit comments