Skip to content

openapi: an object bound on an allOf entry beside a type list is kept on the union, where beside the list the object variant holds it #2062

In progress

Description

@OmarAlJarrah

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}]}

With #1996 (at 253086a):

$ 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 Union in both spellings.
  • A member an entry declares beside a type list (properties on the entry).

Related: #1996, #2039

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

  1. added
    type:bug
    priority:P3
    on Nov 17, 2026
  2. OmarAlJarrah commented on Nov 30, 2026

    @OmarAlJarrah
    MemberAuthor

    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: [object, string], allOf: [{minProperties: 2, minLength: 2}]}

    Entry/type/0 holds minProperties: 2 and Entry/type/1 minLength: 2, as Flat's variants do, and the Union keeps nothing and draws no report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P3type:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions