Repository navigation
Description
Problem
items applies to the elements of the array it is written beside, so an allOf entry writing it constrains the array the position declares as much as the same items written beside the allOf. The two spellings lower apart:
openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
schemas:
Beside: {type: array, items: {type: string}}
Entry: {type: array, allOf: [{items: {type: string}}]}
EntryPrefix: {type: array, allOf: [{prefixItems: [{type: string}]}]}
EntryFormat: {type: string, allOf: [{format: uuid}]}
EntryProps: {type: object, allOf: [{properties: {a: {type: string}}}]}$ 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 a use of one of its conjuncts, which has no home for what this inline branch adds; the branch (items) is kept verbatim under Unmodeled
info openapi/degraded-construct spec.yaml#/components/schemas/EntryPrefix/allOf/0: this allOf lowered to a use of one of its conjuncts, which has no home for what this inline branch adds; the branch (prefixItems) is kept verbatim under Unmodeled
info openapi/degraded-construct spec.yaml#/components/schemas/EntryFormat/allOf/0: this allOf lowered to a use of one of its conjuncts, which has no home for what this inline branch adds; the branch (format) is kept verbatim under Unmodeled
exit 0
$ jq -c '.types | to_entries[] | select(.key | test("schemas/[A-Za-z]+$")) | {id: (.key | split("/") | last), kind: .value.kind, elem: (.value.elem.target // null), base: (.value.base.target // null), props: [.value.properties[]?.name.source], kept: (.value.unmodeled // {} | keys)}' ir.json
{"id":"Beside","kind":"list","elem":"t/prim/string","base":null,"props":[],"kept":[]}
{"id":"Entry","kind":"list","elem":"t/prim/any","base":null,"props":[],"kept":["openapi:allOf/0"]}
{"id":"EntryFormat","kind":"scalar","elem":null,"base":"t/prim/string","props":[],"kept":["openapi:allOf/0"]}
{"id":"EntryPrefix","kind":"list","elem":"t/prim/any","base":null,"props":[],"kept":["openapi:allOf/0"]}
{"id":"EntryProps","kind":"model","elem":null,"base":null,"props":["a"],"kept":[]}Beside is a list of strings. Entry is a list of the top type: the element type is not read, and the entry is kept whole under Unmodeled["openapi:allOf/0"]. EntryPrefix is likewise a list of the top type where a tuple of one string is meant, and EntryFormat a plain string that says nothing of uuid. EntryProps, the contrast, reads the entry's properties as the position's.
Expected: Entry lowers as Beside does, a list of string, and EntryPrefix and EntryFormat as {type: array, prefixItems: [{type: string}]} and {type: string, format: uuid} do, with nothing kept for what each consumed.
docs/compilers/openapi.md#allof-refinement says a format or items written with no type "qualifies a kind and names none, so it decides nothing", because "a schema built from two would stand at a pointer naming neither". That holds for entries that each leave the kind out, as in its {allOf: [{type: integer}, {format: int32}]}. It does not hold here, where the position itself names the kind, so the schema the keyword qualifies is the position's own.
Cause
A refinement folds a keyword of a branch only into a principal that already says it (docs/compilers/openapi.md#allof-refinement), and docs/compilers/openapi.md#allof-inline-residue lists what a branch merges and folds: properties, required, a bare type: object, bounds and annotations. items, prefixItems and format are in neither list, so a branch writing one is kept whole (morphic @9562ea46d).
Direction
A draft: read a branch's items, prefixItems or format as written beside the allOf where the position, or the principal the refinement elects, names the kind they qualify, and keep the branch only where they disagree with what the principal already says. Two entries that each leave the kind out stay as the rule says.
Out of scope
additionalPropertiesandpatternPropertieson an entry besidetype: object, which lower the same way and are openapi: a closure keyword on an inline allOf entry is kept where beside the allOf it closes the model #1998.- Entries that all leave the kind out (
{allOf: [{type: array}, {items: {type: string}}]}), which the rule decides deliberately. - The same keywords beside a
$ref(openapi: a structural keyword beside a 3.1 $ref is kept verbatim, not composed #1067, openapi: a value keyword beside a $ref is kept verbatim where beside an allOf of that $ref it refines #1855).
Priority: P3, rule 3 (off the golden spec; valid-spec functionality a later emitter needs). An allOf inline entry writing items, prefixItems or format and no type:
$ jq '[.. | objects | select((.allOf | type) == "array") | .allOf[] | select(type == "object" and (has("$ref") | not) and (has("type") | not) and (has("items") or has("prefixItems") or has("format")))] | length' openapi.json
0(spec @8b1a4518, morphic @9562ea46d).
Activity
OmarAlJarrah commentedon Nov 17, 2026
Another keyword at the same cause: a
typelist on an inline entry. The in-place merge of an inline entry readstype: objectalone, so a list that also admitsnullis not read, and the entry is kept where the same list beside theallOfis consumed.Both schemas admit exactly what
Tadmits:Tdeclarestype: object, so thenullthe list adds is refused in either spelling.Wrapis theModeloverTwith nothing kept;Entryis the sameModelkeeping the entry with an info (morphic @9562ea46d). With #1996 the entry's keyword is kept underopenapi:typein place ofopenapi:allOf/1, and the two spellings still differ.test(harness): cite the issue behind every reason a record gives
OmarAlJarrah commentedon Nov 28, 2026
Another site of this mechanism: writing
type: arrayon anallOfentry besideitemsorprefixItemson the enclosing schema (e.g.{"items": {"type": "string"}, "allOf": [{"type": "array"}]}), as well as writingtypeon anallOfentry beside any collection or object applicator on the enclosing schema. Both spellings will lower identically with the flat array/object spelling under #2211.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 node built from one conjunct now takes
items,prefixItemsandformatoff whichever conjunct writes them. With the spec here,Entryis aListofstringasBesideis,EntryPrefixaTuple, andEntryFormatauuid, each keeping nothing and drawing no report. From the comments:{allOf: [{$ref: T}, {type: [object, "null"]}]}merges the list and keeps nothing, asWrapdoes, and{items: {type: string}, allOf: [{type: array}]}is aListofstring.