Repository navigation
fix: preserve Java additional properties - #179
Merged
Merged
Conversation
- Retain explicit typed extension values in mixed objects and pure dictionaries instead of silently discarding them through named-field-only Gson models. - Expose independent mutable storage through getAdditionalProperties without changing named constructor parameters or making dictionary models Map subtypes. - Flatten extension entries with verbatim keys, opaque JSON precision and nulls, while retaining declared model, enum, alias, container and recursive codecs. - Disambiguate storage/getter names and reject extension keys that would overwrite declared wire fields, including omitted fields and configured Gson field names. - Delegate ordinary fields through the configured Gson instance, preserving native streaming/tree coercion differences, numeric output and surrounding null policy. - Qualify helper and value identities against authored model names and retain native HTTP request, success and lazy typed-error dictionary payloads. - Keep shared lowering, union-decoder naming defects, other languages, allOf, tagged-wrapper extension storage and generation formatting outside this repair.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
Preserve explicit additional properties in Java OkHttp models, including pure
dictionaries and objects with named fields.
Problem
The IR retains additional-value types, but Java object emission used only named
properties. Gson therefore silently dropped mixed-object extensions and turned
pure dictionaries into empty objects.
Behavior
Models expose typed, mutable
getAdditionalProperties()storage with an independentempty-map default. Existing named constructors and getters stay unchanged.
Configured Gson delegates still own ordinary fields. Native streaming/tree
integer behavior, custom field/value adapters, configured numeric writing and
ordinary null omission remain intact. Extension null preservation restores the
surrounding writer setting even on failure. HTTP JSON requests, successful
responses and lazy typed-error bodies retain their dictionary entries.
Boundaries
Java OkHttp only. Closed/implicit models, alias wrappers, generated dependency
versions, shared lowering and other-language generators are unchanged. General
inline union type loss, primitive-union helper-name collisions, multi-member
allOf and tagged-wrapper extension storage remain separate repairs.
The support uses tree-reader/writer implementation classes from the unchanged
Gson 2.11.0 dependency to retain its native input/output behavior. Native consumers
cover both tree and streaming entrypoints. Ordinary fields are buffered for their
configured delegate rather than reimplemented as a new validation policy.
Generation formatting remains a separate recorded follow-up; this PR does not
add a formatter or claim generated-source formatter conformance.