Skip to content

OpenAPI 3.1.0 self-referential array items with allOf triggers “Elements in allOf must be objects” #10583

@atsuoishimoto

Description

@atsuoishimoto

Q&A (please complete the following information)

  • OS: Windows 11
  • Browser: Chrome
  • Version: 140.0.7339.208
  • Method of installation: dist assets
  • Swagger-UI version: 5.28.0
  • Swagger/OpenAPI version: OpenAPI 3.1

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: test
  description: test
  version: 1.0.0
servers:
  - url: http://localhost:5000
    description: test

paths:
  /api/user:
    get:
      summary: get user
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
    
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        friends:
          type: array
          items:
            type: object
            allOf:
              - $ref: '#/components/schemas/User'
              - type: object
                required:
                  - id

security:
  - {}

Swagger-UI configuration options:

SwaggerUI({
  url: "/schema.yaml",
 dom_id: '#swagger-ui'

Describe the bug you're encountering

Expanding the attached User schema in Swagger UI shows the following error:

Errors
Resolver error at properties.friends.items.allOf
Elements in allOf must be objects

This schema works without error under OpenAPI 3.0.0. Under 3.1.0, the error appears when an object schema has an array property whose items definition combines a self-referential $ref and an allOf that adds constraints.

To reproduce...

  1. Load the OpenAPI 3.1.0 document above in Swagger UI.
  2. Expand components > schemas > User.

Expected behavior

The schema resolves and renders without errors, matching OpenAPI 3.0.0 behavior.

Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions