Skip to content

openapi: an allOf entry kept whole is reported apart from the same keywords beside the allOf, in its count and its words #2057

In progress

Description

@OmarAlJarrah

Problem

With #1996 (at 766a6e4) an inline allOf entry kept whole under openapi:allOf/N is reported by two readers, and the reports differ from the ones the same keywords draw beside the allOf. Two cases.

An entry kept whole for one keyword and also writing not draws two infos for one Unmodeled entry; the first names only the keyword that made it whole:

openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    T: {type: object, properties: {a: {type: string}}}
    Entry: {allOf: [{$ref: '#/components/schemas/T'}, {unevaluatedProperties: false, not: {required: [a]}}]}
$ morphic compile --diag-limit 0 spec.yaml >ir.json; echo "exit $?"
info openapi/validation-only-keyword spec.yaml#/components/schemas/Entry/allOf/1: inline allOf branch is merged in place, and nothing reads the rest of it; the branch (unevaluatedProperties) is kept verbatim under Unmodeled
info openapi/validation-only-keyword spec.yaml#/components/schemas/Entry/allOf/1: validation-only keyword "not" kept verbatim under Unmodeled
exit 0
$ jq -c '.types | to_entries[] | select(.key | test("openapi/components/schemas/Entry$")) | {id: (.key | split("/") | last), kind: .value.kind, kept: (.value.unmodeled // {} | map_values(.reason))}' ir.json
{"id":"Entry","kind":"model","kept":{"openapi:allOf/1":"validation_only"}}

Entry holds one Unmodeled entry, openapi:allOf/1, which holds both keywords, and no openapi:not entry exists for the second info to point at. On main (9562ea4) the same spec keeps two entries (openapi:allOf/1, degraded_lowering, and openapi:not, validation_only) for the two infos, so the count matched what was kept there.

A value set and a union written together draw different words in the two spellings of one schema, at the schema beside the allOf and at the entry on it:

openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    T: {type: string}
    Beside: {allOf: [{$ref: '#/components/schemas/T'}], enum: [a, b], oneOf: [{type: string}, {type: integer}]}
    Entry: {allOf: [{$ref: '#/components/schemas/T'}, {enum: [a, b], oneOf: [{type: string}, {type: integer}]}]}
$ morphic compile --diag-limit 0 spec.yaml >ir.json; echo "exit $?"
info openapi/degraded-construct spec.yaml#/components/schemas/Beside: oneOf/anyOf co-declared with structural keywords intersects with them, and the body is not a model, so it carries no composition to distribute into; union branches kept verbatim under Unmodeled
info openapi/degraded-construct spec.yaml#/components/schemas/Beside/allOf/0: the value set of this allOf narrows this $ref, and one node holds one value set, so the $ref is kept verbatim under Unmodeled; what its target says of the position still reaches it
info openapi/degraded-construct spec.yaml#/components/schemas/Entry/allOf/0: the value set of this allOf narrows this $ref, and one node holds one value set, so the $ref is kept verbatim under Unmodeled; what its target says of the position still reaches it
info openapi/degraded-construct spec.yaml#/components/schemas/Entry/allOf/1: this allOf lowered to a use of one of its allOf conjuncts, which has no home for oneOf written on this inline branch; kept verbatim under Unmodeled
exit 0
$ jq -c '.types | to_entries[] | select(.key | test("openapi/components/schemas/(Beside|Entry)$")) | {id: (.key | split("/") | last), kind: .value.kind, kept: (.value.unmodeled // {} | map_values(.reason))}' ir.json
{"id":"Beside","kind":"enum","kept":{"openapi:$ref":"degraded_lowering","openapi:oneOf":"degraded_lowering"}}
{"id":"Entry","kind":"enum","kept":{"openapi:$ref":"degraded_lowering","openapi:oneOf":"degraded_lowering"}}

The two nodes are the same Enum holding the same two entries, and each draws two infos, but the oneOf is explained by two different sentences (at the schema "the body is not a model, so it carries no composition to distribute into", at the entry "this allOf lowered to a use of one of its allOf conjuncts, which has no home for oneOf"). On main the entry's info repeats the schema's sentence.

Cause

An entry kept whole is reported by two functions of #1996 (at 766a6e4): diagUnmergedBranch (compilers/openapi/internal/schema/allof.go) draws the first info of the first case, naming the keywords that made the entry whole, and recordOwnKeywords (entrykept.go) draws the second through PreserveValidationOnlyKeyword for each validation-only keyword the entry writes, whether or not the entry is held whole. In the second case the entry's sentence is the format string of recordEntryUnhomed (entrykept.go), where beside the allOf the union dispatch (union.go) words the schema's.

Direction

A draft: one info per Unmodeled entry, naming every keyword it holds, and one sentence per reason wherever the keyword is written, so two spellings of one schema read alike. If the two sentences are meant to differ because the two sites do, say so in docs/compilers/openapi.md beside the rule.

Out of scope

  • The $dynamicRef sentence of an entry (its own issue).
  • Whether the oneOf of Beside and Entry should be kept at all, where the value set already says every string it admits.

Related: #1996

Priority: P4, rule 3 (off the golden spec, and diagnostic wording and count). jq '[.. | objects | select(has("allOf")) | .allOf[]? | select(type == "object" and has("not") and (has("unevaluatedProperties") or has("unevaluatedItems")))] | length' openapi.json → 0, and jq '[.. | objects | select(has("allOf")) | select(((has("enum") or has("const")) and (has("oneOf") or has("anyOf"))) or any(.allOf[]?; type == "object" and (has("enum") or has("const")) and (has("oneOf") or has("anyOf"))))] | length' openapi.json → 0 (spec @8b1a4518, morphic @766a6e447).

Activity

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

    @OmarAlJarrah
    MemberAuthor

    Fixed in #2354 at 7213104, which closes this on merge. An entry kept whole now draws one report naming every keyword it holds:

    T: {type: object, properties: {a: {type: string}}}
    Entry: {allOf: [{$ref: '#/components/schemas/T'}, {unevaluatedProperties: false, not: {required: [a]}}]}

    Entry keeps openapi:allOf/1 (validation_only) and draws one info at …/Entry/allOf/1, naming unevaluatedProperties, not, where it drew two. In the second spec, the oneOf kept at Entry is now reported in the words Beside draws ("oneOf/anyOf co-declared with structural keywords intersects with them …"), at …/Entry/allOf/1.

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