[BUG][DART] PATCH tri-state optional handling#23696
Open
radelcom wants to merge 2 commits intoOpenAPITools:masterfrom
Open
[BUG][DART] PATCH tri-state optional handling#23696radelcom wants to merge 2 commits intoOpenAPITools:masterfrom
radelcom wants to merge 2 commits intoOpenAPITools:masterfrom
Conversation
Member
|
cc @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds minimal PATCH tri-state handling for
dart-diowithbuilt_valueserialization.This fixes the PATCH case where the generator needs to preserve three distinct states for nullable fields:
nullThe PR is intentionally scoped to the serialization path only to keep review risk low.
Changes
x-has-optional-propertiesoptional.dartwhenuseOptional=trueoptional.dartin generated built_value models when neededOptional.absent()object.field.isPresentnullwhen the present wrapped value isnullValidation
Validated locally with:
Build result: success.
Also validated by generating a Dart Dio sample from the built CLI jar. Generation completed successfully.
./mvnw clean package with tests enabled hit unrelated existing Kotlin Spring test failures on the local Java 25 environment, so this PR was validated through successful package build and Dart generation behavior.
How to validate
/cc @wing328 @jaumard
Summary by cubic
Fixes PATCH tri-state handling in
dart-diowithbuilt_value, so optional fields correctly support absent, present-null, and present-value. Prevents PATCH payloads from dropping keys or mis-serializing nulls.Optionaland default toOptional.absent().isPresent; emitnullfor present-with-null.optional.dartwhenuseOptional=true; import it only for models withx-has-optional-properties. Also avoid whitespace-only churn in the class template.FullTypeto avoid leakingOptional.Written for commit 6c2ac87. Summary will update on new commits.