Redocly / redoc

📘 OpenAPI/Swagger-generated API Reference Documentation
https://redocly.github.io/redoc/
MIT License
23.47k stars 2.29k forks source link

List of Object referenced in OneOf is not generating sample response #2396

Open sudhakar-plr opened 1 year ago

sudhakar-plr commented 1 year ago

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

ZyzychO commented 1 year ago

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

Stay tuned for updates.

dracz-fl commented 1 week ago

Any chance that this will be fixed soon?