Commit 91580aa
committed
fix: preserve multi-type
When a schema object had both `type: [a, b, c, ...]` and one of
`oneOf`/`anyOf`/`allOf`/`not` on the same level, convert_schema_object
matched an earlier arm that wildcarded the `instance_type` field
(flagged by a pre-existing TODO: "we probably shouldn't ignore this").
The subschema branches were then converted in isolation, silently
discarding the outer type union.
For the schema in issue oxidecomputer#954:
{
"type": ["string", "number", "boolean", "array"],
"oneOf": [
{ "items": { "type": "string" } },
{ "items": { "type": "number" } },
{ "items": { "type": "boolean" } }
]
}
typify produced an enum with only three array variants, losing the
string/number/boolean alternatives entirely.
The fix tightens the match pattern to `None | Some(Single(_))`, letting
`Some(Vec(_))` fall through to the existing merge arm which already
folds the outer schema into each subschema branch via
`try_merge_with_subschemas`. Single-type + subschema behaviour is
preserved, so tolerant handling of schemas whose outer type conflicts
with a branch (e.g. the rust-collisions fixture) is unchanged.
Adds a fixture with eight cases covering the affected code path:
- `type:[...]` combined with oneOf, anyOf, allOf, and not
- explicit `type: array` in every oneOf branch (primitives pruned)
- partially and fully unsatisfiable oneOf
- simultaneous oneOf + allOf
- singleton-type regression guard (rust-collisions pattern)
No existing workspace fixture exercised `type: [...]` alongside
subschemas on the same object, so this fix had zero pre-existing
regression coverage.type union when schema has subschemas (oxidecomputer#954)1 parent ddf42e8 commit 91580aa
3 files changed
Lines changed: 1029 additions & 3 deletions
File tree
- typify-impl/src
- typify/tests/schemas
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
468 | 473 | | |
469 | 474 | | |
470 | | - | |
471 | | - | |
| 475 | + | |
472 | 476 | | |
473 | 477 | | |
474 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments