Description
Q&A (please complete the following information)
- OS: macOS 13.6.7
- Browser: Chrome latest
- Method of installation: standalone Swagger UI (5.17.9), also https://editor-next.swagger.io (UI v. 5.17.3)
- Swagger-UI version: 5.17.9, 5.17.3
- Swagger/OpenAPI version: OpenAPI 3.1 only
Ref swagger-api/swagger-js#3520
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.1.0
info:
title: Example generation test
version: 1.0.0
paths:
/foo:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
components:
schemas:
Foo:
type: object
properties:
bar:
allOf:
- $ref: '#/components/schemas/Bar'
Bar:
type: object
properties:
a:
type: integer
example: 123
b:
type: string
example: hello
Describe the bug you're encountering
The issue may (or may not) be related to #8374.
On the "Example Value" tab, the bar
value appears empty object "bar": {}
instead of an actual object generated from its schema "bar": {"a": 123, "b": "hello"}
. This happens for properties that reference their schema using allOf
+$ref
instead of just $ref
.
The property schema on the "Schema" tab appears correctly though, and shows all fields defined in the referenced schema.
The issue exists for OpenAPI 3.1 definitions and does NOT exist for OpenAPI 3.0 and 2.0.
To reproduce...
Steps to reproduce the behavior:
- Go to https://editor-next.swagger.io
- Paste the definition provided above.
- Expand the
GET /foo
operation and examine the "Example Value".
Actual result:
{
"bar": {}
}
Expected result:
{
"bar": {
"a": 123,
"b": "hello"
}
}
- Replace
openapi: 3.1.0
withopenapi: 3.0.0
. - Example "Example Value" again.
=> Now the example value is correct and includes the nested fields.
Screenshots


Additional context or thoughts
Looks like the correctness of the Example Value depends on whether the user expands the operation or schema first? If I first fully expand the schema under "Schemas" at the bottom, then the Example Value inside the operation is generated correctly.