You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f216da6
Browse filesBrowse the repository at this point in the historyBrowse files
Fix codegen for non-discriminated anyOf unions with mixed types (#171)
Why
===
The encoder generation for TypedDict inputs produces malformed Python
code when handling `anyOf` unions containing mixed types like `[object,
string, array]`.
Before
```python
return (
encode_...AnyOf_0(x)
x
if isinstance(x, str) else
encode_str(x)
)
```
After
```python
return (
encode_...AnyOf_0(x) if isinstance(x, dict) else
x if isinstance(x, str) else
list(x)
)
```
What changed
============
- Collect `(type_check, encoder_expr)` pairs for each union member
- Build a proper ternary chain with `isinstance` checks
- Handle primitive array items by returning `list(x)` instead of undefined encoder calls
Test plan
=========
CI
0 commit comments