Skip to content

Fix a bunch of issues with arrays as properties#942

Merged
msullivan merged 2 commits into
masterfrom
more-arrays
Oct 3, 2025
Merged

Fix a bunch of issues with arrays as properties#942
msullivan merged 2 commits into
masterfrom
more-arrays

Conversation

@msullivan

Copy link
Copy Markdown
Member

Fix json_schema on arrays and multi properties.

Don't use DowncastingTrackedList (which I guess I will now remove in a
follow-up) because we don't want it's behavior of casting things to types
like std.str.

Update the CoreSchemas of arrays, multiprops, and tuples to properly use
the underlying serializers -- for array and multi prop, we want to convert
to a list, and then run a normal pydantic list serializer on the output
type.

Without this, multi props of arrays wouldn't convert the interior arrays
into lists (leaving them as TrackedList), which caused problems like
breaking model_dump_json.

Fixes #937

Don't use DowncastingTrackedList (which I guess I will now remove in a
follow-up) because we don't want it's behavior of casting things to
types like `std.str`.

Update the CoreSchemas of arrays, multiprops, and tuples to properly
use the underlying serializers -- for array and multi prop, we want to
convert to a `list`, and then run a normal pydantic list serializer on
the output type.

Without this, multi props of arrays wouldn't convert the interior
arrays into lists (leaving them as TrackedList), which caused problems
like breaking model_dump_json.
@msullivan msullivan requested review from 1st1, dnwpark and elprans October 1, 2025 22:26
@msullivan msullivan merged commit a92291a into master Oct 3, 2025
43 checks passed
@msullivan msullivan deleted the more-arrays branch October 3, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

model_json_schema fails on objects with array properties

2 participants