Redocly / Redocly/redoc

oneOf not on root is not shown in json samples

Open
#715 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

openapi
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

I'm using version 2.0.0.rc41

When a response consists of a schema with some oneOf elements not at root level only the first possibility is shown on json sample panel.

openapi: 3.0.0
info:
  version: '1.0'
  title: Test
security: []
paths:
  '/test':
    post:
      operationId: test
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/S'
components:
  schemas:
    S:
      type: object
      properties:
        p1:
          oneOf:
            - $ref: '#/components/schemas/S1'
            - $ref: '#/components/schemas/S2'
    S1:
      type: string
    S2:
      type: integer

screenshot from 2018-11-16 13-45-04

If instead the oneOf element is at the root of the response the json sample correctly shows the switching schema buttons.

openapi: 3.0.0
info:
  version: '1.0'
  title: Test
security: []
paths:
  '/test':
    post:
      operationId: test
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                 oneOf:
                  - $ref: '#/components/schemas/S1'
                  - $ref: '#/components/schemas/S2'
components:
  schemas:
    S1:
      type: string
    S2:
      type: integer

screenshot from 2018-11-16 13-48-19

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JSON sample panel using the supplied nested-oneOf OpenAPI example, then compare it with the root-level oneOf behavior. Done means nested oneOf alternatives expose the same switching schema buttons and sample output as the root-level case.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.