Skip to content

openapi: a value set on an allOf entry beside a $ref naming nothing composes a model, where beside the $ref it is the value set #2064

In progress

Description

@OmarAlJarrah

Problem

A value set written on an allOf entry of its own, beside an entry whose $ref names nothing, composes a Model, where the same value set written beside the $ref or beside the allOf lowers as the value set keeping the $ref.

openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    Beside: {$ref: '#/components/schemas/Missing', enum: [a]}
    Wrap: {allOf: [{$ref: '#/components/schemas/Missing'}], enum: [a]}
    Entry: {allOf: [{$ref: '#/components/schemas/Missing'}, {enum: [a]}]}

With #1996 (at 92d4bbe):

$ morphic compile --diag-limit 0 spec.yaml >ir.json; echo "exit $?"
error openapi/unresolved-ref spec.yaml#/components/schemas/Beside: unresolved $ref "#/components/schemas/Missing": […]
error openapi/unresolved-ref spec.yaml#/components/schemas/Entry/allOf/0: unresolved $ref "#/components/schemas/Missing": […]
error openapi/unresolved-ref spec.yaml#/components/schemas/Wrap/allOf/0: unresolved $ref "#/components/schemas/Missing": […]
exit 1
$ jq -c '.types | to_entries[] | select(.key | test("schemas/(Beside|Wrap|Entry)$")) | {id: (.key | split("/") | last), kind: .value.kind, unmodeled: (.value.unmodeled // {} | map_values(.reason))}' ir.json
{"id":"Beside","kind":"enum","unmodeled":{"openapi:$ref":"degraded_lowering"}}
{"id":"Entry","kind":"model","unmodeled":{"openapi:$ref":"degraded_lowering","openapi:enum":"degraded_lowering"}}
{"id":"Wrap","kind":"enum","unmodeled":{"openapi:$ref":"degraded_lowering"}}

The document is refused in every spelling, as it should be, and nothing it writes is lost. What differs is the IR a caller gets beside the error: Entry is a Model, an object type for a schema whose one readable conjunct is a set of strings. On main (at 9562ea4) Entry is a Model too, Wrap an Enum and Beside an alias keeping the enum.

Cause

A reference that names nothing cuts the read of the conjunction short, and a position whose read is cut short composes as before, whatever its other entries say (compilers/openapi/internal/schema, the election of an allOf's conjuncts, at 92d4bbe). The spellings with the value set beside the $ref or the allOf elect the value set first.

Direction

A draft: elect an inline value set on an entry before the cut read decides, as beside the allOf. The alternative is to leave it: an allOf entry whose own $ref names nothing is read whole by a recorded decision, and this is the IR of a refused document.

Out of scope

  • An entry writing the $ref and the value set together, {allOf: [{$ref: Missing, enum: [a]}]}, which is read whole.

Related: #1996, #1568

Priority: P4, rule 2 (the IR of a document refused for an unresolved reference). No count on the golden spec applies: it compiles with no openapi/unresolved-ref (morphic validate openapi.json) (spec @8b1a4518, morphic @92d4bbee3).

Activity

  1. added
    type:bug
    priority:P4
    on Nov 18, 2026
  2. OmarAlJarrah commented on Nov 30, 2026

    @OmarAlJarrah
    MemberAuthor

    Fixed in #2354 at 7213104, which closes this on merge. A value set is now elected before anything is read, so a $ref naming nothing no longer decides the node:

    Entry: {allOf: [{$ref: '#/components/schemas/Missing'}, {enum: [a]}]}

    Entry is the Enum [a] keeping openapi:$ref, as Beside and Wrap are, with the one openapi/unresolved-ref error and no other finding.

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:P4type:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions