Repository navigation
Description
Problem
At OpenAPI 3.0, items "MUST be present if the type is array" (3.0.3, Schema Object). The compiler reports a type: array without items as an openapi/missing-array-items warning, but for an allOf it draws that warning at one entry only: the one the allOf lowers from. Which entry that is decides the verdict, so conjunctions that write the same type: array and the same items get different answers by where the items sits:
openapi: 3.0.3
info: {title: t, version: "1"}
paths: {}
components:
schemas:
X: {type: array, items: {type: string}}
Ref: {allOf: [{$ref: '#/components/schemas/X'}, {type: array}]}
H: {allOf: [{type: array}, {items: {type: string}}]}
J: {allOf: [{type: array}, {type: array, items: {type: string}}]}
K: {allOf: [{type: array, items: {type: string}}, {type: array}]}
B: {allOf: [{type: array}, {type: array}]}$ morphic compile --diag-limit 0 spec.yaml 2>&1 >/dev/null | grep 'warning openapi/missing-array-items' | sed -E 's/: OpenAPI 3.0 requires.*//'
warning openapi/missing-array-items spec.yaml#/components/schemas/H/allOf/0
warning openapi/missing-array-items spec.yaml#/components/schemas/B/allOf/0Hwarns atallOf/0, though the conjunction as a whole declaresitems: the second entry'sitemsconstrains the same elements.JandKare silent, though each has an entry that is atype: arraywriting noitems(J/allOf/0,K/allOf/1), which 3.0's text holds to the rule as it holdsH/allOf/0.Bwarns atallOf/0and never atallOf/1, the same declaration beside it.Ref, the same shape beside a$ref, is silent:docs/compilers/openapi.md#missing-array-itemsreads the conjunction there ("atype: arrayleaves the elements to it").
So the entry that lowers decides the report (J and K lower from the entry that writes items, H and B from one that does not), and the unit of the rule is the entry in one spelling and the conjunction in the other. The rule's text says an inline allOf branch "that merges in place or restates what a refinement names, is not reported", and "the branch a refinement lowers from is reported as the position it is", so each result above follows its letter. The text does not say whether a conjunction that writes items anywhere is to be reported at all, or whether every array entry is.
The question is what the result should be, and the two readings that make it consistent differ in what they report:
- Per schema object, as 3.0's text states the requirement:
H/allOf/0,J/allOf/0,K/allOf/1and both entries ofB(andAbelow), each at its own pointer. A twin entry is then reported as the first is. - Per conjunction, as
Refis already read:H,J,Ksilent, since the conjunction writesitems;Breported once, at the schema or at its first entry. The warning's own claim, "so only its other keywords constrain its elements", is then true of what it names.
With three entries, {allOf: [{type: array}, {type: array}, {items: {type: string}}]} (A), main reports allOf/0 only, the entry the allOf lowers from, which is the case where the two readings differ most: per schema object it is allOf/0 and allOf/1, per conjunction it is silent. #1996 at afb9140 leaves every result above as it is, and moves the report for {allOf: [{type: array}, {type: array, minItems: 1}]} from allOf/0 to allOf/1, the entry its election lowers from.
Cause
schemaBody (compilers/openapi/internal/schema/schema.go) calls missingArrayItems (array.go) for each schema it lowers as a body, so the report is drawn at a position and at the one entry an allOf lowers as a body, the entry it elects; an entry merged in place is never a body and is not read. missingArrayItemsBesideRef is the one reader of a conjunction, for the keywords beside a $ref, through the admission reading (newAdmission); no caller asks an allOf of inline entries whether any entry writes items (morphic @9562ea46d).
Direction
A draft, with a real choice between the two readings above. Per conjunction needs the admission reading (newAdmission, as missingArrayItemsBesideRef already uses it) for inline entries too, and makes the 3.0 requirement a statement about what the schema as a whole constrains, which is how the rule treats a $ref. Per schema object needs the report at each array entry the lowering merges, which the rule currently exempts, and a statement that a warning at an entry a conjunct elsewhere covers is correct because 3.0 says so of the object. Either way docs/compilers/openapi.md#missing-array-items says which, and a case holds H, J, K and B to it.
Out of scope
- The
itemsan entry writes beside a declared array lowering to a list of the top type, with the entry kept verbatim (openapi: an items on an allOf entry beside a declared array is kept, where beside the allOf it types the list #2039):AandHlower to a list ofanywith theiritemsunderUnmodeled. - 3.1 and 3.2, where
itemsis optional and nothing is reported.
Priority: P4, rule 2 (the warning is about a document violating 3.0's text, and what it reports is diagnostic volume and placement). jq '[.. | objects | select(.type == "array" and (has("items") | not))] | length' openapi.json → 0: no schema of the golden spec is an array without items (spec @8b1a4518, morphic @9562ea46d).
Activity
test(harness): record what a second keyword finds outside the core
test(compilers/openapi): pin the reach decisions' issue rows
OmarAlJarrah commentedon Nov 30, 2026
Decided and fixed in #2354 at acf4512, which closes this on merge: per conjunction (
docs/compilers/openapi.md#missing-array-items). Oneopenapi/missing-array-itemswarning is drawn at the position where no conjunct, a$ref's target included, writesitems. With the spec here,H,J,K,AandRefdraw none, andBdraws one, atB. A position composing a target that draws its own is reported too:RefY: {allOf: [{$ref: Y}, {type: array}]}overY: {type: array}draws one atRefYbesideY's.test(internal/harness): drop the reasons no case finding gives