Examples referenced with $ref are not rendered correctly
See original GitHub issueNot sure if a regression of https://github.com/swagger-api/swagger-ui/issues/4021
This renders the example but also adds the $$ref key
openapi: '3.0.0'
info:
title: 'test'
version: '1.0.0'
paths:
/hello:
get:
description: 'Get welcome message.'
responses:
'200':
description: 'welcome message'
content:
application/json:
schema:
$ref: '#/components/schemas/Welcome'
example:
$ref: '#/components/examples/WelcomeExample'
components:
schemas:
Welcome:
type: object
properties:
message:
type: string
examples:
WelcomeExample:
value:
api_identifier: act_12345
And this one shows the $ref key instead of parsing it (Although the editor shows an error if the $ref doesn’t exist):
openapi: '3.0.0'
info:
title: 'test'
version: '1.0.0'
paths:
/hello:
get:
description: 'Get welcome message.'
responses:
'200':
description: 'welcome message'
content:
application/json:
schema:
$ref: '#/components/schemas/Welcome'
example:
$ref: '#/components/examples/WelcomeExample'
components:
schemas:
Welcome:
type: object
properties:
message:
type: string
examples:
WelcomeExample:
value:
api_identifier: act_12345
All of this tested in the swagger editor.
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (6 by maintainers)
Top Results From Across the Web
How to correct a #REF! error - Microsoft Support
The #REF! error shows when a formula refers to a cell that's not valid. This happens most often when cells that were referenced...
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
Relative references used in $ref are processed as per JSON Reference, using the URL of the current document as the base URI. See...
Read more >openapi - Swagger schema properties ignored when using $ref
A possible workaround is to wrap $ref into allOf - this can be used to "add" attributes to a $ref but not override...
Read more >HTML elements reference - HTML: HyperText Markup Language
The text is typically rendered using a non-proportional, or monospaced, font. Whitespace inside this element is displayed as written.
Read more >OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
When properly defined via OpenAPI, a consumer can understand and interact with ... 4.7.23.1 Fixed Fields; 4.7.23.2 Reference Object Example ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would like add another argument to the case for resolution. Is the current behavior for schemas. As a developer trying to define an API, I don’t see why I can have nested schema references but not nested example references.
From my point of view, what is wrong in this example is the
value
key being rendered. Why can I reuse schemas but not examples?Encountering the same issue. Is anyone working on it?