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
feat: generate typed tuples for fixed-length positional items
Positional item schemas — 2020-12 `prefixItems` and the draft-04
`items: [A, B]` spelling — were parsed and then discarded, so every tuple
generated `Vec<serde_json::Value>`. gcore said it out loud, in the description
directly above the generated field: "First element of the tuple is a key, the
second one is its counter value."
The length is the load-bearing part. `prefixItems` alone does not cap an
array's length — extra elements of any type are legal unless `items: false`,
`additionalItems: false`, or `maxItems` says otherwise — and a Rust tuple is
fixed-arity, so mapping every `prefixItems` to one would emit code that
compiles and then fails on payloads the spec permits. Three tiers instead:
1. length pinned -> a tuple, one element per position;
2. closed, variable length, positions interchangeable -> `Vec<T>`;
3. otherwise -> `Vec<serde_json::Value>`, unchanged.
A `$ref` position keeps its named type and an inline object position is
hoisted to one, so `analyze_item_schema` now takes the hoist name explicitly
rather than deriving it from the parent.
Also models 2020-12 boolean schemas for `items`: `items: false` is the
canonical way to close a tuple and did not parse at all, failing the whole
document the way #60 did.
Closes#62
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TD3TSeWKu4VqLtEnRMDjry
0 commit comments