Repository navigation
Description
Problem
With #1996 (at 766a6e4) a $dynamicRef on an allOf entry is kept verbatim and reported as "written on an allOf entry beside another conjunct, which the IR cannot intersect with it". That is the reason only where the allOf has another conjunct. On an allOf of one entry there is none, yet the same report is drawn, and the keyword is kept where the same schema written without the allOf is expanded:
openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
schemas:
M: {$dynamicAnchor: m, type: object, properties: {m: {type: string}}}
Bare: {$dynamicRef: '#m'}
Lone: {allOf: [{$dynamicRef: '#m'}]}
Beside: {allOf: [{$ref: '#/components/schemas/M'}, {$dynamicRef: '#m'}]}$ morphic compile --diag-limit 0 spec.yaml >ir.json; echo "exit $?"
info openapi/dynamic-ref-expanded spec.yaml#/components/schemas/Bare/$dynamicRef: $dynamicRef expanded to "t/openapi/components/schemas/M", the one matching $dynamicAnchor in this document
info openapi/degraded-construct spec.yaml#/components/schemas/Lone/allOf/0/$dynamicRef: $dynamicRef was not expanded because it is written on an allOf entry beside another conjunct, which the IR cannot intersect with it; it is kept verbatim under Unmodeled
info openapi/degraded-construct spec.yaml#/components/schemas/Beside/allOf/1/$dynamicRef: $dynamicRef was not expanded because it is written on an allOf entry beside another conjunct, which the IR cannot intersect with it; it is kept verbatim under Unmodeled
exit 0
$ jq -c '.types | to_entries[] | select(.key | test("openapi/components/schemas/(Bare|Lone|Beside)$")) | {id: (.key | split("/") | last), kind: .value.kind, base: (.value.base.target // null), kept: (.value.unmodeled // {} | map_values(.reason))}' ir.json
{"id":"Bare","kind":"scalar","base":"t/openapi/components/schemas/M","kept":{}}
{"id":"Beside","kind":"model","base":"t/openapi/components/schemas/M","kept":{"openapi:$dynamicRef":"degraded_lowering"}}
{"id":"Lone","kind":"scalar","base":"t/prim/any","kept":{"openapi:$dynamicRef":"degraded_lowering"}}Beside is the case the sentence describes. Lone has no other conjunct, so the stated reason is false for it, and it lowers to an alias of the top type holding openapi:$dynamicRef, where Bare, the same schema without the allOf, is an alias of M. On main (9562ea4) Lone is a Model with no base keeping the entry under openapi:allOf/0, reported as "inline allOf branch is merged in place, and nothing reads the rest of it", so the false sentence is new to #1996.
Cause
keepEntryDynamicRef (compilers/openapi/internal/schema/entrykept.go) keeps the keyword of an inline entry and draws the report for every one, on the ground its comment gives, that "no entry expands one, as it is a conjunct the IR cannot intersect with the rest". The sentence never asks whether the allOf has a rest (#1996 at 766a6e4).
Direction
A draft: where the entry is the only conjunct the keyword expands as it does written bare, with the same info; where another conjunct exists the sentence stays. The alternative, if a lone entry is meant to be kept, is a sentence that gives the reason that holds for it.
Out of scope
- A
$dynamicRefbeside a$refwhere the position has no carrier (openapi: a $dynamicRef beside a $ref is dropped where the position has no carrier #2009). - A reference naming an entry that writes a
$dynamicRef(its own issue).
Priority: P4, rule 3 (off the golden spec, and diagnostic wording). jq '[.. | objects | select(has("$dynamicRef"))] | length' openapi.json → 0 (spec @8b1a4518, morphic @766a6e447).
Activity
test(compilers/openapi): pin the reach decisions' issue rows
OmarAlJarrah commentedon Nov 30, 2026
Fixed in #2354 at acf4512, which closes this on merge. An
allOfentry is now read as the composition listing it reaches it, and the only entry stands in place:Lone: {allOf: [{$dynamicRef: '#m'}]}expands asBaredoes, to theModeloverM, with the sameopenapi/dynamic-ref-expandedinfo and nothing kept. Nested one-entryallOfs around such an entry expand the same way.Besidekeeps its$dynamicRefwith the sentence about another conjunct, which is true of it.