List of Object referenced in OneOf is not generating sample response
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
Redoc possibly not creating the 'Sample response' when using OneOf referencing array of objects(same type).
Below is the sample API definition:
openapi: 3.0.3
info:
title: Simple Pets API
description: |-
This is a sample Pets API showcasing some `oneOf` scenarios
version: 0.0.1
tags:
- name: pets
description: Everything about your Pets
paths:
/animals:
get:
tags:
- pets
summary: Get pets from catalog
description: Returns a list of pets found on the server
operationId: getAnimals
responses:
'200':
description: successful operation
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
components:
schemas:
Animal:
type: object
properties:
breed:
type: string
example: poodle
Cat:
type: array
items:
$ref: '#/components/schemas/Animal'
Dog:
type: array
items:
$ref: '#/components/schemas/Animal'
Actual Behaviour: No sample response generated in swagger documentation
Expected behaviour: Sample response for array of objects need to generated in the swagger
"[
{
"breed":"poodle"
}
]"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in Redoc with the OpenAPI definition provided in the report, focusing on sample response generation for oneOf schemas referencing arrays. Trace that generation path and add coverage for the example; done means the documentation shows the expected array containing an object with the breed value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100