Skip to content

Schema with deeply nested allOf / oneOf intermittently renders incorrectly #10523

@scottohara

Description

@scottohara

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: 138
  • Method of installation: dist assets
  • Swagger-UI version: 5.26.0
  • Swagger/OpenAPI version: OpenAPI 3.0.1

Content & configuration

Note

Although the YAML example here may seem contrived, please note that it was taken from an actual (much larger) real world spec, anonymised, and then reduced to a minimal example that demonstrates the issue.

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: Example
  version: 1.0.0
paths:
  /example:
    get:
      responses:
        '200':
          description: Empty
components:
  schemas:
    A:
      type: object
      properties:
        a:
          $ref: '#/components/schemas/B'
    B:
      allOf:
        - $ref: '#/components/schemas/C'
        - $ref: '#/components/schemas/D'
    C:
      type: object
      properties:
        c:
          type: string
    D:
      type: object
      properties:
        d:
          $ref: '#/components/schemas/E'
    E:
      type: array
      items:
        $ref: '#/components/schemas/F'
    F:
      type: object
      properties:
        f:
          $ref: '#/components/schemas/G'
    G:
      oneOf:
        - $ref: '#/components/schemas/H'
        - $ref: '#/components/schemas/I'
    H:
      allOf:
        - $ref: '#/components/schemas/J'
        - $ref: '#/components/schemas/K'
    I:
      allOf:
        - $ref: '#/components/schemas/B'
        - $ref: '#/components/schemas/K'
    J:
      allOf:
        - type: object
          properties:
            j:
              type: string
        - $ref: '#/components/schemas/C'
    K:
      type: object
      properties:
        k:
          type: string

Swagger-UI configuration options:

Reproducible in https://editor.swagger.io/

Important

In the screen recording attached, I am demonstrating the issue using Swagger Editor.
(It was difficult to reliably reproduce it on-demand in Swagger UI, given the intermittent nature).
I can, however, confirm that the issue does intermittently occur in Swagger UI as well.

Describe the bug you're encountering

It will be easiest to describe the issue by referencing specific timestamps in the attached screen recording:

Timestamp Description
[00:00] The expanded schema on the right shows the definition G = oneof H or I
[00:05] This correctly matches the YAML definition of G on the left
[00:10] A edit is made, triggering a re-render
[00:18] The rendered definition still correctly shows G = one of H or I
[00:22] A second edit is made, triggering another re-render
[00:29] The rendered definition now incorrectly shows G = one of H or B

It is worth noting that the example includes some deeply nested allOf / oneOf definitions; as well as a circular reference (B -> ... -> G -> I, where I then references back to B).

Given the intermittent nature of the issue, it is possible that the combination of nested allOf / oneOf, and/or the circular reference causes a race condition where, depending on the order in which references are resolved, the outcome for G is either correctly "one of H or I", or incorrectly "one of H or B".

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor.swagger.io/
  2. Paste the above YAML into the editor
  3. In the Schemas section rendered on the right, expand the A schema until G is expanded
  4. Note that G is correctly rendered as "oneof H or I" (confirm in the definition on the left that this is correct)
  5. Make a trivial edit (e.g. rename the A.a -> A.x)
  6. Expand the schema on the right and check the definition of G

(Note: You may need to repeat steps 5-6 more than once to trigger the issue)

Expected behavior

The rendered definition of G should always be oneof H or I.

Screenshots

Screen.Recording.2025-07-08.at.12.48.34.pm.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions