From 2d5e6dae4473cb2f3f71257033cc6c5102b1b079 Mon Sep 17 00:00:00 2001 From: fern-support Date: Wed, 11 Mar 2026 21:28:32 +0000 Subject: [PATCH 1/2] Add Swift and Rust custom code pages and update language card lists Co-Authored-By: bot_apk --- fern/products/sdks/custom-code.mdx | 4 + .../sdks/overview/rust/custom-code.mdx | 133 ++++++++++++++++++ .../sdks/overview/swift/custom-code.mdx | 103 ++++++++++++++ .../reference/generators-yml-reference.mdx | 2 + fern/products/sdks/sdks.yml | 6 + 5 files changed, 248 insertions(+) create mode 100644 fern/products/sdks/overview/rust/custom-code.mdx create mode 100644 fern/products/sdks/overview/swift/custom-code.mdx diff --git a/fern/products/sdks/custom-code.mdx b/fern/products/sdks/custom-code.mdx index 6f73f8ea3..9b7c63674 100644 --- a/fern/products/sdks/custom-code.mdx +++ b/fern/products/sdks/custom-code.mdx @@ -82,4 +82,8 @@ You'll have a separate `.fernignore` file for each of your SDKs: } href="/sdks/generators/ruby/custom-code"> + + + + diff --git a/fern/products/sdks/overview/rust/custom-code.mdx b/fern/products/sdks/overview/rust/custom-code.mdx new file mode 100644 index 000000000..39d6e3851 --- /dev/null +++ b/fern/products/sdks/overview/rust/custom-code.mdx @@ -0,0 +1,133 @@ +--- +title: Adding custom code +headline: Adding custom code (Rust) +description: Augment your Rust SDK with custom utilities, methods, and dependencies. +--- + + + +This page covers how to add custom logic, methods, and dependencies to your Rust SDK. + + + +## Adding custom logic + +To get started adding custom code: + + + + ```rust title="src/helper.rs" + pub fn my_helper() { + println!("Hello World!"); + } + ``` + + Register the module in `src/lib.rs`: + + ```rust title="src/lib.rs" + pub mod helper; + ``` + + + ```yaml {3-4} title=".fernignore" + # Specify files that shouldn't be modified by Fern + + src/helper.rs + src/lib.rs + ``` + + + + + ```rust + use your_crate::helper; + + helper::my_helper(); + ``` + + + +## Adding custom SDK methods + + + + + + Name your Fern-generated client something like `BaseClient` to reflect that this client will be extended. + + ```yaml {4} title="generators.yml" + - name: fernapi/fern-rust-sdk + version: + config: + clientClassName: BaseClient + ``` + + + Create a new client that wraps the Fern generated base client and adds your custom methods. + + ```rust title="src/my_client.rs" + use crate::BaseClient; + + pub struct MyClient { + inner: BaseClient, + } + + impl MyClient { + pub fn new(inner: BaseClient) -> Self { + Self { inner } + } + + pub fn my_helper(&self) { + println!("Hello World!"); + } + } + + impl std::ops::Deref for MyClient { + type Target = BaseClient; + + fn deref(&self) -> &Self::Target { + &self.inner + } + } + ``` + + + Add `my_client.rs` to `.fernignore`. + + ```diff title=".fernignore" + + src/my_client.rs + ``` + + + Instead of constructing the generated client, your users will want to construct the extended client. + + ```rust + use your_crate::my_client::MyClient; + + let base = your_crate::BaseClient::builder() + .base_url("https://api.example.com") + .build(); + let client = MyClient::new(base); + ``` + + + + ```rust + client.my_helper(); + ``` + + + +## Adding custom dependencies + +To add crates that your custom code requires, update your `generators.yml`. + +```yaml {4-7} title="generators.yml" +- name: fernapi/fern-rust-sdk + version: + config: + extraDependencies: + tokio: "1.0" + extraDevDependencies: + mockall: "0.11" +``` diff --git a/fern/products/sdks/overview/swift/custom-code.mdx b/fern/products/sdks/overview/swift/custom-code.mdx new file mode 100644 index 000000000..62324bb87 --- /dev/null +++ b/fern/products/sdks/overview/swift/custom-code.mdx @@ -0,0 +1,103 @@ +--- +title: Adding custom code +headline: Adding custom code (Swift) +description: Augment your Swift SDK with custom utilities, methods, and dependencies. +--- + + + +This page covers how to add custom logic, methods, and dependencies to your Swift SDK. + + + +## Adding custom logic + +To get started adding custom code: + + + + ```swift title="Sources/Helper.swift" + public enum Helper { + public static func myHelper() { + print("Hello World!") + } + } + ``` + + + ```yaml {3} title=".fernignore" + # Specify files that shouldn't be modified by Fern + + Sources/Helper.swift + ``` + + + + + ```swift + import YourModule + + Helper.myHelper() + ``` + + + +## Adding custom SDK methods + + + + + + Name your Fern-generated client something like `BaseClient` to reflect that this client will be extended. + + ```yaml {4} title="generators.yml" + - name: fernapi/fern-swift-sdk + version: + config: + clientClassName: BaseClient + ``` + + + First, import the Fern generated base client and extend it. Then, add whatever methods you want. + + ```swift title="Sources/MyClient.swift" + import Foundation + + public class MyClient: BaseClient { + public func myHelper() { + print("Hello World!") + } + } + ``` + + + Add `MyClient.swift` to `.fernignore`. + + ```diff title=".fernignore" + + Sources/MyClient.swift + ``` + + + Instead of constructing the generated client, your users will want to construct the extended client. + + ```swift + import YourModule + + let client = MyClient() + ``` + + + + ```swift + client.myHelper() + ``` + + + +## Adding custom dependencies + +To add packages that your custom code requires, update the `Package.swift` in your SDK repository directly. Add the custom dependency to your `.fernignore` to ensure it persists across regenerations. + +```diff title=".fernignore" ++ Package.swift +``` diff --git a/fern/products/sdks/reference/generators-yml-reference.mdx b/fern/products/sdks/reference/generators-yml-reference.mdx index f8cf9b4aa..8dd8952a8 100644 --- a/fern/products/sdks/reference/generators-yml-reference.mdx +++ b/fern/products/sdks/reference/generators-yml-reference.mdx @@ -554,6 +554,8 @@ groups: + + diff --git a/fern/products/sdks/sdks.yml b/fern/products/sdks/sdks.yml index 6399742de..9ef442724 100644 --- a/fern/products/sdks/sdks.yml +++ b/fern/products/sdks/sdks.yml @@ -207,6 +207,9 @@ navigation: - page: Publishing as a Swift package path: ./overview/swift/publishing-to-swift-package-manager.mdx slug: publishing + - page: Adding custom code + path: ./overview/swift/custom-code.mdx + slug: custom-code - changelog: ./overview/swift/changelog slug: changelog - section: Rust @@ -220,6 +223,9 @@ navigation: - page: Publishing to crates.io path: ./overview/rust/publishing-to-crates-io.mdx slug: publishing + - page: Adding custom code + path: ./overview/rust/custom-code.mdx + slug: custom-code - changelog: ./overview/rust/changelog slug: changelog - section: Postman From c97d37bd40787fc5e96fc761faca44f32a3eae3e Mon Sep 17 00:00:00 2001 From: fern-support Date: Fri, 13 Mar 2026 11:04:59 +0000 Subject: [PATCH 2/2] Revert new pages; keep only Rust config card on generators-yml reference Co-Authored-By: bot_apk --- fern/products/sdks/custom-code.mdx | 4 - .../sdks/overview/rust/custom-code.mdx | 133 ------------------ .../sdks/overview/swift/custom-code.mdx | 103 -------------- fern/products/sdks/sdks.yml | 6 - 4 files changed, 246 deletions(-) delete mode 100644 fern/products/sdks/overview/rust/custom-code.mdx delete mode 100644 fern/products/sdks/overview/swift/custom-code.mdx diff --git a/fern/products/sdks/custom-code.mdx b/fern/products/sdks/custom-code.mdx index 9b7c63674..6f73f8ea3 100644 --- a/fern/products/sdks/custom-code.mdx +++ b/fern/products/sdks/custom-code.mdx @@ -82,8 +82,4 @@ You'll have a separate `.fernignore` file for each of your SDKs: } href="/sdks/generators/ruby/custom-code"> - - - - diff --git a/fern/products/sdks/overview/rust/custom-code.mdx b/fern/products/sdks/overview/rust/custom-code.mdx deleted file mode 100644 index 39d6e3851..000000000 --- a/fern/products/sdks/overview/rust/custom-code.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -title: Adding custom code -headline: Adding custom code (Rust) -description: Augment your Rust SDK with custom utilities, methods, and dependencies. ---- - - - -This page covers how to add custom logic, methods, and dependencies to your Rust SDK. - - - -## Adding custom logic - -To get started adding custom code: - - - - ```rust title="src/helper.rs" - pub fn my_helper() { - println!("Hello World!"); - } - ``` - - Register the module in `src/lib.rs`: - - ```rust title="src/lib.rs" - pub mod helper; - ``` - - - ```yaml {3-4} title=".fernignore" - # Specify files that shouldn't be modified by Fern - - src/helper.rs - src/lib.rs - ``` - - - - - ```rust - use your_crate::helper; - - helper::my_helper(); - ``` - - - -## Adding custom SDK methods - - - - - - Name your Fern-generated client something like `BaseClient` to reflect that this client will be extended. - - ```yaml {4} title="generators.yml" - - name: fernapi/fern-rust-sdk - version: - config: - clientClassName: BaseClient - ``` - - - Create a new client that wraps the Fern generated base client and adds your custom methods. - - ```rust title="src/my_client.rs" - use crate::BaseClient; - - pub struct MyClient { - inner: BaseClient, - } - - impl MyClient { - pub fn new(inner: BaseClient) -> Self { - Self { inner } - } - - pub fn my_helper(&self) { - println!("Hello World!"); - } - } - - impl std::ops::Deref for MyClient { - type Target = BaseClient; - - fn deref(&self) -> &Self::Target { - &self.inner - } - } - ``` - - - Add `my_client.rs` to `.fernignore`. - - ```diff title=".fernignore" - + src/my_client.rs - ``` - - - Instead of constructing the generated client, your users will want to construct the extended client. - - ```rust - use your_crate::my_client::MyClient; - - let base = your_crate::BaseClient::builder() - .base_url("https://api.example.com") - .build(); - let client = MyClient::new(base); - ``` - - - - ```rust - client.my_helper(); - ``` - - - -## Adding custom dependencies - -To add crates that your custom code requires, update your `generators.yml`. - -```yaml {4-7} title="generators.yml" -- name: fernapi/fern-rust-sdk - version: - config: - extraDependencies: - tokio: "1.0" - extraDevDependencies: - mockall: "0.11" -``` diff --git a/fern/products/sdks/overview/swift/custom-code.mdx b/fern/products/sdks/overview/swift/custom-code.mdx deleted file mode 100644 index 62324bb87..000000000 --- a/fern/products/sdks/overview/swift/custom-code.mdx +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: Adding custom code -headline: Adding custom code (Swift) -description: Augment your Swift SDK with custom utilities, methods, and dependencies. ---- - - - -This page covers how to add custom logic, methods, and dependencies to your Swift SDK. - - - -## Adding custom logic - -To get started adding custom code: - - - - ```swift title="Sources/Helper.swift" - public enum Helper { - public static func myHelper() { - print("Hello World!") - } - } - ``` - - - ```yaml {3} title=".fernignore" - # Specify files that shouldn't be modified by Fern - - Sources/Helper.swift - ``` - - - - - ```swift - import YourModule - - Helper.myHelper() - ``` - - - -## Adding custom SDK methods - - - - - - Name your Fern-generated client something like `BaseClient` to reflect that this client will be extended. - - ```yaml {4} title="generators.yml" - - name: fernapi/fern-swift-sdk - version: - config: - clientClassName: BaseClient - ``` - - - First, import the Fern generated base client and extend it. Then, add whatever methods you want. - - ```swift title="Sources/MyClient.swift" - import Foundation - - public class MyClient: BaseClient { - public func myHelper() { - print("Hello World!") - } - } - ``` - - - Add `MyClient.swift` to `.fernignore`. - - ```diff title=".fernignore" - + Sources/MyClient.swift - ``` - - - Instead of constructing the generated client, your users will want to construct the extended client. - - ```swift - import YourModule - - let client = MyClient() - ``` - - - - ```swift - client.myHelper() - ``` - - - -## Adding custom dependencies - -To add packages that your custom code requires, update the `Package.swift` in your SDK repository directly. Add the custom dependency to your `.fernignore` to ensure it persists across regenerations. - -```diff title=".fernignore" -+ Package.swift -``` diff --git a/fern/products/sdks/sdks.yml b/fern/products/sdks/sdks.yml index 9ef442724..6399742de 100644 --- a/fern/products/sdks/sdks.yml +++ b/fern/products/sdks/sdks.yml @@ -207,9 +207,6 @@ navigation: - page: Publishing as a Swift package path: ./overview/swift/publishing-to-swift-package-manager.mdx slug: publishing - - page: Adding custom code - path: ./overview/swift/custom-code.mdx - slug: custom-code - changelog: ./overview/swift/changelog slug: changelog - section: Rust @@ -223,9 +220,6 @@ navigation: - page: Publishing to crates.io path: ./overview/rust/publishing-to-crates-io.mdx slug: publishing - - page: Adding custom code - path: ./overview/rust/custom-code.mdx - slug: custom-code - changelog: ./overview/rust/changelog slug: changelog - section: Postman