redoc icon indicating copy to clipboard operation
redoc copied to clipboard

List of Object referenced in OneOf is not generating sample response

Open sudhakar-plr opened this issue 2 years ago • 3 comments

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" } ]"

sudhakar-plr avatar Aug 30 '23 08:08 sudhakar-plr

Hey @sudhapublic! We can confirm the issue on our end. Thanks for the report!

Stay tuned for updates.

ZyzychO avatar Sep 08 '23 15:09 ZyzychO