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
Copy file name to clipboardExpand all lines: fern/products/sdks/guides/setup-local-sdk-previews.mdx
+23-10Lines changed: 23 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,42 @@
1
1
---
2
-
title: Setup local SDK previews
3
-
subtitle: Use Fern's CLI tool to preview your SDK locally.
2
+
title: Set up local SDK previews
3
+
description: Use Fern's CLI tool to preview your SDK locally.
4
4
---
5
5
6
-
[Once you configure your SDK](/learn/sdks/getting-started/generate-your-first-sdk), you can preview the generated SDK code using Fern's CLI.
6
+
Once you configure your SDK, you can use the `--preview` flag to test generated
7
+
SDK code locally before publishing. This allows quick iteration on your Fern definition
8
+
as you develop:
7
9
8
-
Simply append the `--preview` flag to the command used to generate the SDK and you will see the generated code populated in a `.preview` folder within your `fern` folder.
10
+
```bash
11
+
# Preview all SDKs
12
+
fern generate --preview
9
13
10
-
<Tiptitle="Custom Code">
11
-
[If you have added custom code to your SDK](/learn/sdks/capabilities/augment-with-custom-code), `--preview` will
12
-
preserve those changes.
14
+
# Preview SDK for a specific language
15
+
fern generate --group <language>-sdk --preview
16
+
17
+
```
18
+
19
+
`--preview` generates your SDK code into a local `.preview/` folder within your
20
+
`fern` folder. No changes are published to package managers or GitHub.
21
+
22
+
<Tip>
23
+
`--preview` preserves any custom code you added to your SDK.
13
24
</Tip>
14
25
15
-
Here's an example of how you can preview your SDK:
26
+
## Example usage
27
+
28
+
Here's an example of how you can preview a Python SDK.
0 commit comments