Fix deserialization of anyOf types with lists #30
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.
It was good that you added support for deserializing anyOf types because there's also a case for that in the OpenAI API (although they have not adjusted the spec appropriately yet - openai/openai-openapi#99).
When you create an embedding, OpenAI can return the embedding as a list of floats or as a base64-encoded string. So the schema looks like this:
The previous implementation was generating the following JSON converter:
However, it failed to deserialize a list of floats because
data
is of typeList<dynamic>
, which is not aList<double>
.This PR changes the condition to check that
data
is aList
and all the items of the list are of the specified type.This is how the new JSON converter looks like:
cc @walsha2