Skip to content

Commit 7abffdc

Browse files
Kapil GowruKapil Gowru
authored andcommitted
Merge remote-tracking branch 'origin/main' into 07-21-redirects-1
2 parents 3ee940d + ba2db6d commit 7abffdc

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ If you use Fern's SDK Generator, you can automatically show SDK code snippets in
1111

1212
## Configuring SDK Snippets
1313

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

1616
### Add examples to your API definition
1717

1818
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/).
1919

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

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+
2226
<CodeBlock title="generators.yml">
23-
```yaml
27+
```yaml {9, 16, 22, 26}
2428
groups:
2529
production:
2630
generators:
@@ -57,15 +61,18 @@ groups:
5761
</Callout>
5862

5963
### 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/`.
6167

6268
<CodeBlock title="docs.yml">
63-
```yaml
69+
```yaml {4-7}
6470
navigation:
6571
- api: API Reference
6672
snippets:
6773
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
6976
go: https://github.com/your-organization/your-repository # <--- needs the https://github.com/ prefix
7077
```
7178
</CodeBlock>

fern/products/sdks/guides/setup-local-sdk-previews.mdx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
---
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.
44
---
55

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

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
913

10-
<Tip title="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.
1324
</Tip>
1425

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.
1629

1730
<Steps>
1831
### Generator configuration
19-
```yaml generators.yml
32+
```yaml title="generators.yml" {4}
2033
api:
2134
path: ./path/to/openapi.yml
2235
groups:
2336
python-sdk:
2437
generators:
2538
- name: fernapi/fern-python-sdk
26-
version: 3.0.0
39+
version: <Markdown src="/snippets/version-number.mdx"/>
2740
output:
2841
location: pypi
2942
package-name: imdb

0 commit comments

Comments
 (0)