hello, currently it's not possible to define an example for a request body if I reference another object. only default/null values are shown as example.
This can be seen here: (example is empty since no properties defined for Configuration)
openapi: 3.0.0
info:
description: what a description
version: 1.0.0
title: API Docs
servers:
- url: 'https://some.url.net'
paths:
/some/path:
post:
summary: THis is a summary
description: This should be a long description...
requestBody:
description: Optional description in *Markdown*
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Configuration'
example:
sources:
- id: '1'
lat: 52.450411
lng: 13.43755
responses:
'200':
description: Totally cool
components:
schemas:
Configuration:
type: object

If we change this to that:
openapi: 3.0.0
info:
description: what a description
version: 1.0.0
title: API Docs
servers:
- url: 'https://some.url.net'
paths:
/some/path:
post:
summary: THis is a summary
description: This should be a long description...
requestBody:
description: Optional description in *Markdown*
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Configuration'
responses:
'200':
description: Totally cool
components:
schemas:
Configuration:
type: object
example:
sources:
- id: '1'
lat: 52.450411
lng: 13.43755

Then this works as expected, but forces me to use one example for all requests, I also validated this against another OpenAPI Viewer (Koumoul).
Hope this get's fixed soon.
Thanks, Daniel
Swagger UI does not currently display the example and examples defined under content.<media-type> - see https://github.com/swagger-api/swagger-ui/issues/3437. The workaround is to use schema-level examples.
This is not a really a workaround since I have to use the same example everywhere :(
This should be fixed now 馃槃
Most helpful comment
This is not a really a workaround since I have to use the same example everywhere :(