Repository navigation
Description
Problem
A type list lowers to a Union whose variants each take the bounds their own type takes, so an object bound written beside the list is the object variant's. The same bound written on an allOf entry beside the list reaches no variant.
openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
schemas:
Flat: {type: [object, string], minProperties: 2, minLength: 2}
Entry: {type: [object, string], allOf: [{minProperties: 2, minLength: 2}]}$ morphic compile --verify --diag-limit 0 spec.yaml >ir.json; echo "exit $?"
info openapi/degraded-construct spec.yaml#/components/schemas/Entry/allOf/0: this allOf lowered to what the keywords beside it say, as no entry of it is the one it lowers from […]
exit 0
$ jq -c '.types | to_entries[] | select(.key | test("schemas/(Flat|Entry)")) | {id: (.key | sub("^t/[a-z]+/components/schemas/"; "")), kind: .value.kind, cons: (.value.constraints // null), unmodeled: (.value.unmodeled // {} | map_values(.reason))}' ir.json
{"id":"Entry/type/0","kind":"model","cons":null,"unmodeled":{}}
{"id":"Entry/type/1","kind":"scalar","cons":{"minLength":2,"uniqueItems":false},"unmodeled":{}}
{"id":"Flat/type/0","kind":"model","cons":{"uniqueItems":false,"minProps":2},"unmodeled":{}}
{"id":"Flat/type/1","kind":"scalar","cons":{"minLength":2,"uniqueItems":false},"unmodeled":{}}
{"id":"Entry","kind":"union","cons":null,"unmodeled":{"openapi:minProperties":"degraded_lowering"}}
{"id":"Flat","kind":"union","cons":null,"unmodeled":{}}Both schemas say the same thing: an object of at least two members, or a string of at least two characters. Flat's object variant holds minProps: 2. Entry's string variant holds minLength, as Flat's does, but its object variant holds no bound, and minProperties is kept verbatim on the Union. Nothing is lost, and a consumer reading the object variant's Constraints misses a bound the schema states. Expected: Entry's object variant holds minProps: 2, as Flat's does, with nothing kept.
On main (at 9562ea4) Entry is a Model holding both minLength and minProps, the type list kept under openapi:type: an object where the schema also admits a string.
Cause
The object variant of a type list is built with no reading of the allOf entries beside the list, so a bound an entry writes is folded only onto the scalar variants, each for its own kinds (compilers/openapi/internal/schema, the refinement's bound homes, at 253086a).
Direction
A draft: build the object variant with the entries' object bounds, as the scalar variants take theirs, so the two spellings are one document.
Out of scope
- A bound no variant's type takes, which is kept on the
Unionin both spellings. - A member an entry declares beside a
typelist (propertieson the entry).
Priority: P3, rule 3 (off the golden spec). jq '[.. | objects | select((.type | type) == "array" and (.allOf | type) == "array")] | length' openapi.json → 0: no schema of the golden spec writes a type list beside an allOf (spec @8b1a4518, morphic @253086ad5).
Activity
fix(compilers/openapi): hold a bound beside a union-shaped principal
test(compilers/openapi): hold keywords split across allOf to flat twins
OmarAlJarrah commentedon Nov 30, 2026
Fixed in #2354 at acf4512, which closes this on merge. A type list's object variant now reads the conjuncts beside the list, as its scalar variants do:
Entry/type/0holdsminProperties: 2andEntry/type/1minLength: 2, asFlat's variants do, and theUnionkeeps nothing and draws no report.