redoc
redoc copied to clipboard
OpenAPI 3.1 examples not rendered correctly
Describe the bug
Having an array of examples in a schema definition, e.g. under #/components/schemas only renders the first one, not all of them.
Expected behavior I expect to see all examples in the right pane.
Minimal reproducible OpenAPI snippet(if possible)
components:
schemas:
Test:
type: object
properties:
id:
type: integer
title:
type: string
examples:
- id: 123
title: Test title
- id: 456
title: Another title
Screenshots
Additional context
In openapi 3.1, example is deprecated. According to changes from openapi 3.0 to 3.1 (https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0) one should use examples instead of example and add several examples as a list.
It doesn't work either when adding multiple examples to the individual fields instead of the object, i.e.
components:
schemas:
Test:
type: object
properties:
id:
type: integer
title:
type: string
examples:
- Test title
- Another title
also shows only the first one.
I expect to the all examples either directly listed or selectable (although openapi 3.1 examples are a list, not a hash with keys to select from). Since objects can become complex and properties may depend on each other, showing several real world examples with different use cases make sense.
This is not really a bug.
OpenAPI 3.1 also allows for defining mutliple media type examples. If you want multiple examples displayed, use that instead because that provides a key to put into an example selector.
+1 for this feature request since only displaying the first example appears to be the current functionality.
We should think about UI this feature. The main idea is easy to copy and paste mock data for requests.
How we can display multiple examples? One way we can add a new dropdown for it, but it seems too complicated to understand and we have concerns about naming these keys.
It seems super simple but it is not. What about complicated schemas with many key examples? How it should display?
If there are ideas we will be glad to hear them. We don't have a good UI solution for that now.