You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Redoc renders only one example, and the content is an empty array [ ].
The request body schema on the other hand correctly shows two options, with one of them being the type itself and the other being an array of the same type.
Only the example generation is the issue here.
Edit for clarification:
Redoc is only generating one example while it should generate two (this is due to the examples having the same key and overwriting each other).
The generated example is wrong (an empty array).
Expected behavior
There are two examples, one example of the type and other of the type in an array.
Minimal reproducible OpenAPI snippet(if possible)
If you give me an editor where I can edit the openapi.yaml and see the Redoc result I can create one.
Below is how the schema currently uses the MetaOrganisation schema.
Redoc does not sync the examples window with the main column. related #2346
I'll just note for clarity that #2346 is only tangentially related as it also mentions oneOf and the same part of the UI but the similarities end there.
Of course #2346 would be nice-to-have as well if the examples were being generated at all. However for me #2346 is just that, nice-to-have, but this issue (#2676) is more of a blocker.
I added some clarification to the issue description as well just in case.
thanks for describing more information. it seems you're onto a few things, first the title duplication. I tried adding different titles to each subschema and it created the first oneOf without any issue but it still has the empty array for the second one.
the sampler is passing schema.oneOf[0] as the selectedSubSchema function argument rather than iterating through the array and is only taking the first oneOf instance when traversing the list of schemas.
Describe the bug
When having a schema as follows
Redoc renders only one example, and the content is an empty array
[ ]
.The request body schema on the other hand correctly shows two options, with one of them being the type itself and the other being an array of the same type.
Only the example generation is the issue here.
Edit for clarification:
Expected behavior
There are two examples, one example of the type and other of the type in an array.
Minimal reproducible OpenAPI snippet(if possible)
If you give me an editor where I can edit the
openapi.yaml
and see the Redoc result I can create one.Below is how the schema currently uses the MetaOrganisation schema.
Screenshots
This is correct:
This is the generated example(s):
This is how it looks like in swagger-ui:
Swagger-ui only displays one of the examples. If the
oneOf
order is swapped then it renders this:Additional context
Redoc version:
2.4.0
After debugging this a bit, there are actually two issues here:
subSchema.title
here has the same value ("OrganisationMembership"
) for both the type and the array of the same type, which means that only the last example inoneOf
is kept. https://github.com/Redocly/redoc/blob/v2.4.0/src/services/models/MediaType.ts#L69oneOf
order will also render one example in redoc:Sampler
returns[]
as the sample for the array of type example. https://github.com/Redocly/redoc/blob/v2.4.0/src/services/models/MediaType.ts#L63The text was updated successfully, but these errors were encountered: