feat: support null-friendly parameters #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
With this feature enabled, users can now pass null directly:
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.
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.