Skip to content

Commit 7d4294e

Browse files
authored
Clarify supported languages for SDK snippets, add C# syntax (Docs) (#653)
1 parent c3bff7c commit 7d4294e

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

fern/products/docs/pages/api-references/sdk-snippets.mdx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ title: Display SDK snippets
33
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.
44
---
55

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>
79

810
<Frame>
911
![SDK code snippet selector](https://fern-image-hosting.s3.amazonaws.com/sdk-code-snippets.png)
1012
</Frame>
1113

1214
## Configuring SDK Snippets
1315

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`.
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>
1519

1620
### Add examples to your API definition
1721

@@ -20,7 +24,7 @@ In order to generate code snippets, Fern needs to read request examples from you
2024
### Define a package name for your SDK(s)
2125

2226
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.
2428
* For **Go**, add `repository: your-organization/your-repository` to the `github` section.
2529

2630
<CodeBlock title="generators.yml">
@@ -29,26 +33,32 @@ groups:
2933
production:
3034
generators:
3135
- name: fernapi/fern-python-sdk
32-
version: 2.8.0
36+
version: <Markdown src="/snippets/version-number-python.mdx" />
3337
output:
3438
location: pypi
3539
token: ${PYPI_TOKEN}
3640
package-name: your-package-name # <--- add this field
3741
...
3842
- name: fernapi/fern-typescript-node-sdk
39-
version: 0.20.9
43+
version: <Markdown src="/snippets/version-number-ts.mdx" />
4044
output:
4145
location: npm
4246
token: ${NPM_TOKEN}
4347
package-name: your-package-name # <--- add this field
4448
- name: fernapi/fern-ruby-sdk
45-
version: 0.6.3
49+
version: <Markdown src="/snippets/version-number-ruby.mdx" />
4650
output:
4751
location: rubygems
4852
token: ${RUBYGEMS_TOKEN}
4953
package-name: your-package-name # <--- add this field
54+
- name: fernapi/fern-csharp-sdk
55+
version: <Markdown src="/snippets/version-number-csharp.mdx" />
56+
output:
57+
location: nuget
58+
api-key: ${NUGET_API_KEY}
59+
package-name: your-package-name # <--- add this field
5060
- name: fernapi/fern-go-sdk
51-
version: 0.22.0
61+
version: <Markdown src="/snippets/version-number-go.mdx" />
5262
github:
5363
repository: your-organization/your-repository # <--- add this field
5464
...
@@ -62,7 +72,7 @@ groups:
6272

6373
### Add the package name to your docs configuration
6474
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.
6676
* **For Go**, use the exact URL where the SDK repository is located, including the `https://github.com/`.
6777

6878
<CodeBlock title="docs.yml">
@@ -73,6 +83,7 @@ navigation:
7383
python: your-package-name # <--- needs to match the naming in generators.yml
7484
typescript: your-package-name # <--- needs to match the naming in generators.yml
7585
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
7687
go: https://github.com/your-organization/your-repository # <--- needs the https://github.com/ prefix
7788
```
7889
</CodeBlock>
@@ -87,17 +98,6 @@ As the final step, trigger your docs generation by running `fern generate --docs
8798

8899
### Set default snippet language
89100

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-
101101
To set the default snippet language, use the `default-language` key at the top indentation level of `docs.yml`.
102102

103103
<CodeBlock title="docs.yml">
@@ -112,6 +112,8 @@ navigation:
112112
```
113113
</CodeBlock>
114114

115+
</Steps>
116+
115117
## Access via API
116118

117119
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

Comments
 (0)