Skip to content

Conversation

@tstanmay13
Copy link
Contributor

New pattern introduced here which we need to update fern-api/fern#8372

@tstanmay13 tstanmay13 requested a review from dsinghvi July 25, 2025 17:35
@github-actions
Copy link
Contributor

@promptless
Copy link
Contributor

promptless bot commented Jul 25, 2025

📝 Documentation updates detected!

New suggestion: Add Java SDK builder extensibility documentation with Template Method pattern

@github-actions
Copy link
Contributor

## Adding custom client configuration

When you need to intercept and transform client configuration before the SDK client is created, you can extend the generated builder classes. This allows you to add custom code and logic during the client initialization process.
The Java SDK generator now supports builder extensibility through a template method pattern. By extending the generated builder classes and overriding protected methods, you can customize how your SDK client is configured without modifying generated code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lets delete now since these docs will be forever

```

### Create a custom builder with your transformation logic
### Create a custom builder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lets add class Create a custom builder class


### Update `.fernignore`

Add the `MyClient.java` and `MyClientBuilder.java` to `.fernignore`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding these two files to .fernignore, fern will not update them on new generations.

@Override
protected void setEnvironment(ClientOptions.Builder builder) {
String baseUrl = this.environment.getUrl();
String tenantUrl = baseUrl.replace("/api/", "/api/tenants/" + tenantId + "/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lets get rid of the duplicative api

@tstanmay13 tstanmay13 merged commit 21822e8 into main Jul 25, 2025
1 check passed
@tstanmay13 tstanmay13 deleted the java/update-custom-codev2 branch July 25, 2025 19:56
@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants