From 1146bb9bde8ad5a5cc7dbe97ab79bc2edfd07b82 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Fri, 18 Jul 2025 10:14:23 -0400 Subject: [PATCH 1/2] add snippets to typescript page and fix python format errors --- .../sdks/overview/python/custom-code.mdx | 22 +++++++++---------- .../sdks/overview/typescript/custom-code.mdx | 22 +++++-------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/fern/products/sdks/overview/python/custom-code.mdx b/fern/products/sdks/overview/python/custom-code.mdx index 946e3df8d..4938422d7 100644 --- a/fern/products/sdks/overview/python/custom-code.mdx +++ b/fern/products/sdks/overview/python/custom-code.mdx @@ -16,7 +16,7 @@ description: Augment your Python SDK with custom utilities ```python title="src//helper.py" def my_helper() -> None: - print "Hello World!" + print("Hello World!") ``` ### Add your file to `.fernignore` @@ -78,17 +78,15 @@ description: Augment your Python SDK with custom utilities First, import the Fern generated base clients from `.base_client.py` and extend them to create your custom clients. Then, add whatever methods you want. - ```python title="src//client.py" - from .base_client import \ - BaseClient - - class YourClient(BaseClient): - - def my_helper(self) -> None - print("Hello World") - - ``` - + ```python title="src//client.py" + from .base_client import BaseClient // import generated client + + class YourClient(BaseClient): // extend generated client + def my_helper(self) -> None: + print("Hello World!") + def my_helper(self) -> None: + print("Hello World") + ``` See an example [client.py](https://github.com/elevenlabs/elevenlabs-python/blob/main/src/elevenlabs/client.py) from ElevenLabs. diff --git a/fern/products/sdks/overview/typescript/custom-code.mdx b/fern/products/sdks/overview/typescript/custom-code.mdx index 1b1dd32bb..7713ae41b 100644 --- a/fern/products/sdks/overview/typescript/custom-code.mdx +++ b/fern/products/sdks/overview/typescript/custom-code.mdx @@ -3,21 +3,11 @@ title: Adding custom code description: Augment your TypeScript SDK with custom utilities --- -Fern-generated SDKs are designed to be extended with custom code. Your custom -code can add additional functionality to the SDK and live in harmony with the -generated code. This page explains how to configure custom logic using a -`.fernignore` file, create custom SDK methods, and add additional dependencies to your SDK. + ## Adding custom logic -If you want your SDK to do more than just make basic API calls (like combining -multiple calls, processing data, adding utilities), you can use `.fernignore` to -protect your custom code from being overwritten during regeneration. - -Simply add your custom files to the SDK repository and list them out in `.fernignore`. Fern -won't override any files that you add in `.fernignore`. - -To get started adding custom code: + @@ -42,7 +32,7 @@ To get started adding custom code: ### Consume the helper - Now your users can consume the helper function by importing it from the SDK: + ```typescript import { myHelper } from "sdk/helper"; @@ -53,9 +43,7 @@ To get started adding custom code: ## Custom SDK methods - Fern also allows you to add custom methods to the SDK itself (e.g. - `client.my_method()` ). by inheriting the Fern generated client and then - extending it. + See an example from Flatfile using this process in their [TypeScript SDK](https://github.com/FlatFilers/flatfile-node) @@ -111,7 +99,7 @@ To get started adding custom code: ### Consume the method - Now your users can consume the helper function by importing it from the SDK: + ```typescript client.myHelper() From d2bba777b1bc93c2e6a71904abb87206b3d95049 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Fri, 18 Jul 2025 10:26:26 -0400 Subject: [PATCH 2/2] other misc nit edits --- fern/products/sdks/overview/dotnet/quickstart.mdx | 2 +- fern/products/sdks/overview/go/quickstart.mdx | 2 +- fern/products/sdks/overview/java/configuration.mdx | 2 +- fern/products/sdks/overview/java/quickstart.mdx | 2 +- fern/products/sdks/overview/php/quickstart.mdx | 2 +- fern/products/sdks/overview/python/quickstart.mdx | 2 +- fern/products/sdks/overview/ruby/configuration.mdx | 4 ++-- fern/products/sdks/overview/ruby/quickstart.mdx | 2 +- fern/products/sdks/overview/typescript/custom-code.mdx | 8 ++++---- fern/products/sdks/overview/typescript/quickstart.mdx | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fern/products/sdks/overview/dotnet/quickstart.mdx b/fern/products/sdks/overview/dotnet/quickstart.mdx index 5b7e934c1..623175438 100644 --- a/fern/products/sdks/overview/dotnet/quickstart.mdx +++ b/fern/products/sdks/overview/dotnet/quickstart.mdx @@ -78,7 +78,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ csharp └─ src/ diff --git a/fern/products/sdks/overview/go/quickstart.mdx b/fern/products/sdks/overview/go/quickstart.mdx index d1eeace0b..9bc1ff170 100644 --- a/fern/products/sdks/overview/go/quickstart.mdx +++ b/fern/products/sdks/overview/go/quickstart.mdx @@ -78,7 +78,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ go ├─ core/ diff --git a/fern/products/sdks/overview/java/configuration.mdx b/fern/products/sdks/overview/java/configuration.mdx index bc4440483..9f3fa7261 100644 --- a/fern/products/sdks/overview/java/configuration.mdx +++ b/fern/products/sdks/overview/java/configuration.mdx @@ -12,7 +12,7 @@ groups: - name: fernapi/fern-java-sdk version: config: - client_class_name: YourApiClient + client-class-name: YourApiClient ``` ## SDK Configuration Options diff --git a/fern/products/sdks/overview/java/quickstart.mdx b/fern/products/sdks/overview/java/quickstart.mdx index a2b2a4fd3..9c1f430b5 100644 --- a/fern/products/sdks/overview/java/quickstart.mdx +++ b/fern/products/sdks/overview/java/quickstart.mdx @@ -78,7 +78,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ java ├─ YourOrganizationApiClient.java diff --git a/fern/products/sdks/overview/php/quickstart.mdx b/fern/products/sdks/overview/php/quickstart.mdx index f86afc05e..fff4c8833 100644 --- a/fern/products/sdks/overview/php/quickstart.mdx +++ b/fern/products/sdks/overview/php/quickstart.mdx @@ -78,7 +78,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ php └─ sdk/ diff --git a/fern/products/sdks/overview/python/quickstart.mdx b/fern/products/sdks/overview/python/quickstart.mdx index 4e458d510..00769436a 100644 --- a/fern/products/sdks/overview/python/quickstart.mdx +++ b/fern/products/sdks/overview/python/quickstart.mdx @@ -78,7 +78,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ python ├─ __init__.py diff --git a/fern/products/sdks/overview/ruby/configuration.mdx b/fern/products/sdks/overview/ruby/configuration.mdx index a65da8cf9..8664d1d51 100644 --- a/fern/products/sdks/overview/ruby/configuration.mdx +++ b/fern/products/sdks/overview/ruby/configuration.mdx @@ -10,10 +10,10 @@ default-group: local groups: local: generators: - - name: fernapi/fern-python + - name: fernapi/fern-ruby version: config: - clientName: YourClientName + clientClassName: YourClientName ``` ## SDK Configuration Options diff --git a/fern/products/sdks/overview/ruby/quickstart.mdx b/fern/products/sdks/overview/ruby/quickstart.mdx index 1fb0907e5..4bba86429 100644 --- a/fern/products/sdks/overview/ruby/quickstart.mdx +++ b/fern/products/sdks/overview/ruby/quickstart.mdx @@ -78,7 +78,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ ruby ├─ YourOrganization_api_client.gemspec diff --git a/fern/products/sdks/overview/typescript/custom-code.mdx b/fern/products/sdks/overview/typescript/custom-code.mdx index 7713ae41b..790fc91e9 100644 --- a/fern/products/sdks/overview/typescript/custom-code.mdx +++ b/fern/products/sdks/overview/typescript/custom-code.mdx @@ -15,7 +15,7 @@ description: Augment your TypeScript SDK with custom utilities ```typescript title="src/helper.ts" export function myHelper(): void { - return console.log("Hello world!"); + return console.log("Hello world!"); } ``` @@ -76,11 +76,11 @@ description: Augment your TypeScript SDK with custom utilities Update your `index.ts` file to export the **extended client** instead of the generated client. ```typescript title="src/index.ts" - export { MyClient } from src/wrapper/MyClient; // instead of `src/Client` + export { MyClient } from "src/wrapper/MyClient"; // instead of "src/client" ``` - See an example [index.ts](https://github.com/FlatFilers/flatfile-node/blob/main/src/index.ts) from Flatline + See an example [index.ts](https://github.com/FlatFilers/flatfile-node/blob/main/src/index.ts) from Flatfile ### Update `.fernignore` @@ -93,7 +93,7 @@ description: Augment your TypeScript SDK with custom utilities ``` - See an example [.fernignore](https://github.com/FlatFilers/flatfile-node/blob/main/.fernignore) from Flatline + See an example [.fernignore](https://github.com/FlatFilers/flatfile-node/blob/main/.fernignore) from Flatfile diff --git a/fern/products/sdks/overview/typescript/quickstart.mdx b/fern/products/sdks/overview/typescript/quickstart.mdx index fd8c4a9f4..ea7e56808 100644 --- a/fern/products/sdks/overview/typescript/quickstart.mdx +++ b/fern/products/sdks/overview/typescript/quickstart.mdx @@ -76,7 +76,7 @@ This command adds the following to `generators.yml`: ```bash -fern/ # created in step 1 +fern/ # created by fern init sdks/ # created by fern generate --group sdk ├─ typescript ├─ Client.ts