fix: support primitive members in composed types - #142
Merged
Vincent Biret (baywet) merged 1 commit intoAug 27, 2026
Merged
Conversation
Vincent Biret (baywet)
requested changes
Aug 26, 2026
Andrea Peruffo (andreaTP)
force-pushed
the
fix/composed-type-primitive-members
branch
2 times, most recently
from
August 27, 2026 09:46
30d8392 to
ebda42f
Compare
- scalar readers return nil on a type mismatch, matching dotnet and Python - get_collection_of_primitive_values dispatched on the class, so no branch ever matched - write_*_value(nil, value) discarded the scalar instead of storing it
Andrea Peruffo (andreaTP)
force-pushed
the
fix/composed-type-primitive-members
branch
from
August 27, 2026 10:10
ebda42f to
e1ee161
Compare
Vincent Biret (baywet)
approved these changes
Aug 27, 2026
Vincent Biret (baywet)
left a comment
Member
There was a problem hiding this comment.
Thank you for making the changes!
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.
Composed-type support was implemented and tested for object members only; every existing spec uses a Parsable. The primitive paths were written speculatively and never had a consumer, so three defects went unnoticed until a generator emitted them (microsoft/kiota#8065).
Deserialization could not discriminate. JsonParseNode's scalar getters coerce -- get_string_value is to_s, get_number_value is to_i -- so every getter answers for any payload and a union always selected its first member. Rather than making the existing getters type-strict, which would break clients that rely on coercion, add try_get_string_value / try_get_boolean_value / try_get_number_value / try_get_float_value. These return nil unless the node really is that type. Integer and Float stay distinct because JSON already distinguishes 1 from 1.0.
Serialization discarded scalars. write_*_value(nil, value) returned the value without storing it, so a composed type whose selected member was a primitive serialized to {}. A nil key now means "this scalar is the document"; the writer keeps a root value and get_serialized_content emits it. The guards also tested falsiness rather than nil, so writing
falseraised.write_object_value dropped members after a leading nil:
return unless valuediscarded the remaining arguments, losing every member of an intersection whose first member was unset. It now compacts before writing.Adds specs for each, including a
falsevalue and a leading-nil intersection.