Skip to content

feat: support null-friendly parameters #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vishalg0wda
Copy link

@vishalg0wda vishalg0wda commented Jul 10, 2025

This PR enables the nullFriendlyParameters feature in Java SDK generation, significantly simplifying how SDK end users provide optional and nullable values.

💡 What’s Changing
Prior to this change, end users had to wrap values explicitly:

.setMyParameter(Optional.empty());
.setAnotherParameter(JsonNullable.of(null));

With this feature enabled, users can now pass null directly:

.setMyParameter(null);
.setAnotherParameter(null);

This improves:

Developer experience – Cleaner, more idiomatic Java usage.

IDE feedback – JetBrains users get nullability hints via jakarta @Nullable / @NonNull annotations.

API cleanliness – Wrapper types like JsonNullable are handled internally and no longer leak into user code.

⚠️ Breaking Change — Rollout Considerations
This introduces breaking changes to method signatures and generated types. Any SDKs regenerating with this flag enabled will break compatibility for existing consumers.

As such:

This change must be released behind a version bump (typically a major version).

🤔 PATCH Semantics and Null Handling
A common concern with this change is how null values behave in PATCH-like operations, where setting a field to null often carries different intent than omitting it entirely.

To clarify:

✅ Nullable fields → passing null results in an explicit null being sent.

✅ Optional fields → passing null causes the field to be omitted from the request.

✅ Nullable + Optional fields → passing null results in null being sent; to omit, simply avoid calling the setter.

The generated SDK code handles this distinction under the hood, by converting values internally to the appropriate JsonNullable or JsonUndefined types - so users don’t have to manage those concerns themselves.

Copy link
Contributor

@Amzani Amzani left a comment

Choose a reason for hiding this comment

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

Thanks @vishalg0wda for the PR, I’ll first need to assess the impact of this change on our existing customers before including it in the upcoming release.

Regarding the PR itself, it should only include changes to the gen.yaml file, since the actual SDK generation is managed by our CI pipeline.

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.

2 participants