Example Swagger/OpenAPI definition:
openapi: '3.0.1'
info:
title: 'Title'
version: 1.0.0
components:
schemas:
object:
type: object
example:
a:
$ref: '#/components/schemas/object/properties/a/example'
properties:
a:
type: string
example: 'aString'
paths:
'/path':
post:
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/object'
responses:
'201':
description: 'description'
Swagger-UI configuration options:
I don't know the configuration. This bug happens on https://editor.swagger.io/ and also on swagger-ui-watcher.
Steps to reproduce the behavior:
$ref as a property of the JSON.This is what you should see:
{
"a": {
"$ref": "#/components/schemas/object/properties/a/example"
}
}
The JSON should be:
{
"a": "aString"
}


If you go to the Model, it will show example: aString, which is correct.
If you embed the schema within the requestBody schema manually, everything works as expected:
openapi: '3.0.1'
info:
title: 'Title'
version: 1.0.0
components:
schemas:
object:
type: object
example:
a:
$ref: '#/components/schemas/object/properties/a/example'
properties:
a:
type: string
example: 'aString'
paths:
'/path':
post:
requestBody:
required: true
content:
application/json:
schema:
type: object
example:
a:
$ref: '#/components/schemas/object/properties/a/example'
properties:
a:
type: string
example: 'aString'
responses:
'201':
description: 'description'
Result:

Hi @dosentmatter, thanks for filing an issue!
@webron, what should be happening here? I don't see Reference Objects mentioned in the Example Object section of the specification, but I do see $refs used in the examples. Please advise 馃槃
Hey @shockey, no problem!
I just noticed that this bug only happens when you update the yaml while the POST /path is expanded and the example json is visible. So it might be a bug with swagger-editor instead. I updated the steps to reproduce the issue. If the issue is in swagger-editor, we can move the issue over there.
If you keep POST /path collapsed, update the yaml, then expand it, it works as expected.
ping @webron
Sorry for the delay here. The way it works right now is as expected. As @shockey mentioned, there's no support for $ref for examples inside the Schema Object. As such, it should treat the $ref as the example itself.
Thanks, @webron - closing this 馃槃