Repository navigation
fix: preserve Python additional properties - #178
Merged
Merged
Conversation
- Generate typed mutable extension storage for explicit additional-property facts in both Python transports instead of dropping entries or emitting empty models. - Expose keyword-only additional_properties fields with independent empty defaults and flatten their entries through normal from_dict and to_dict conversion. - Retain verbatim extension keys, opaque nulls and large integers while converting declared model, enum, nullable, container, alias and recursive value types. - Keep authored field names intact, disambiguate extension storage names and reject extension keys that would overwrite or impersonate declared wire fields. - Reuse planned value codecs for dictionary fields, HTTP payloads and lazy errors, preserving union policies, native exceptions and cached error-body failures. - Match dictionary models and mixed-object extension values through explicit dataclass metadata without serializing candidates during union selection. - Defer typed factories across recursive imports and keep built-in factory and Any helper identities distinct from authored fields and models. - Preserve existing tagged helper keyword parameters and ordinary nullable-field omission while keeping authored union-null semantics intact. - Retain native transport/declaration consumers and exact render/golden contracts without changing generated dependencies, shared lowering or other backends. - Keep multi-member allOf, tagged-wrapper extension storage and opaque inline composition facts outside this object-model preservation 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 Python httpx and requests clients,
including both pure dictionaries and objects with named fields.
Problem
The IR already retains dictionary value facts, but Python object emission used
only named properties. A mixed-object round-trip therefore silently discarded
every extension entry. Pure dictionaries became empty dataclasses without normal
from_dict/to_dictconversion.Behavior
Models now expose typed, mutable, keyword-only
additional_propertiesstoragewith an independent empty-dict default. Conversion separates known wire fields
from extension entries and writes them back as one flat JSON object.
ValueError, even when the named field is omittedAliases, recursive dictionaries, containing models and union boundaries retain
the same typed value conversions. Dictionary models participate in outbound
matching through their declared storage, without invoking codecs to count union
candidates. Existing firstMatch, strict and raw policies still govern union
values. HTTP JSON requests, successful responses and lazy typed error bodies use
the same codecs, including native decode failures and error caching.
Factory and typing helper references remain distinct from authored names such as
field,dict,additionalPropertiesandAny. Factory type references aredeferred so recursive model imports stay usable.
Boundaries
This covers both Python transports only. Existing named constructor parameters,
closed/implicit objects and ordinary field codecs remain intact; extension
storage is an additive keyword-only field. Existing tagged helper keyword
parameters and ordinary optional/nullable field omission remain unchanged.
Generated source and dependency manifests are consumed without compatibility
patches.
Shared IR/lowering, other-language generators, multi-member
allOfcompositionand tagged-wrapper extension storage are not redesigned. General inline composed
additional-property schemas that already lower as opaque values remain opaque;
that existing loss of type facts is a separate lowering repair. This change
converts the retained value facts, not a new JSON Schema validation policy.