fix: wrapper types for intersection types should not be serialized as objects#97
Merged
baywet merged 9 commits intoMar 7, 2025
Conversation
baywet
reviewed
Mar 5, 2025
Contributor
Author
|
I also think this is related to #95. @wisamidris77 can you check if the changes in this branch also fix your issue? |
This reverts commit b717325.
c1a33c3 to
f4d9a33
Compare
Contributor
Author
baywet
previously approved these changes
Mar 7, 2025
baywet
left a comment
Member
There was a problem hiding this comment.
Thanks for providing more context. After doing a comparison with dotnet I think you're implementation is correct.
We don't need the marker interface since it's empty and would not provide much here.
And we can rely on the shape of the serialized value to know whether we need to unwrap a scalar value instead.
baywet
previously approved these changes
Mar 7, 2025
baywet
approved these changes
Mar 7, 2025
Merged
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.
This fixes an edge case I have seen with the OpenAI API spec.
Some models have an intersection type property. This causes a wrapper type to be generated that holds a property for each possible type in the intersection.
Currently, the serializer writes this wrapper type as its own object. The correct serialization would "flatten" this type, so only its value remains.