-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Open
Labels
pull-request-welcomeIf a PR were to be made, we would help get it mergedIf a PR were to be made, we would help get it mergedspecification: 3.1OpenAPI 3.1 specificOpenAPI 3.1 specific
Description
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
$ref: '#/components/schemas/User'
required:
- id
Swagger-UI configuration options:
SwaggerUI({
url: "/schema.yaml",
dom_id: '#swagger-ui'
})
Is your feature request related to a problem?
Expanding the attached OpenAPI 3.1.0 User schema in Swagger UI results in the friends property (an array that self-references User) being displayed as array, and the UI shows only a raw $ref-like string such as:
$ref=http://localhost:5000/schema.yaml#/components/schemas/User
The property definition is not expanded.
Figure 1. The self-referential property is rendered as the $ref schema name.

Describe the solution you'd like
The friends array should render as an array of User objects with the schema expanded (e.g., array<User>
).
Additional context
With OpenAPI 3.0.0, a similar schema defined using allOf
expands correctly in Swagger UI (see below). Under OpenAPI 3.1.0, the allOf-based definition is not usable because it triggers an error in Swagger UI 5.28.0 (#10583).
openapi: 3.0.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
Figure 2. The self-referential property defined with allOf is correctly expanded(OpenAPI 3.0).

Metadata
Metadata
Assignees
Labels
pull-request-welcomeIf a PR were to be made, we would help get it mergedIf a PR were to be made, we would help get it mergedspecification: 3.1OpenAPI 3.1 specificOpenAPI 3.1 specific