Redocly / Redocly/redoc

Bad title of oneOf-Switch button in allOf

Open
#995 2 comments 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

ReDoc version: 2.0.0-rc.12
OpenAPI: 3.0.0

If the whole schema is a oneOf-block, the switch buttons are showing the sub-schema name as title.
If the schema is a allOf-block which contains items which are oneOf-blocks, the title is just "object" or "object or object".

Redoc Problem

Here's the example code in YAML format:

---
openapi: 3.0.0

info:
  title: oneOf Test
  version: 1.0.0

paths:
  "/test":
    get:
      summary: Test
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Data"

components:
  schemas:
    Woman:
      properties:
        haircolor:
          type: string
    Man:
      properties:
        weight:
          type: integer

    Young:
      properties:
        schoolName:
          type: string
    Old:
      properties:
        employerName:
          type: string

    Data:
      allOf:
      - type: object
        properties:
          id:
            type: integer
          name:
            type: string
      - oneOf:
        - "$ref": "#/components/schemas/Woman"
        - "$ref": "#/components/schemas/Man"
      - oneOf:
        - "$ref": "#/components/schemas/Young"
        - "$ref": "#/components/schemas/Old"
      - properties:
          language:
            type: string

And here, the same in JSON format:

{
  "openapi": "3.0.0",

  "info": {
    "title": "oneOf Test",
    "version": "1.0.0"
  },

  "paths": {
    "/test": {
      "get": {
        "summary": "Test",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Data" }
              }
            }
          }
        }
      }
    }
  },

  "components": {
    "schemas": {
      "Woman": {
        "properties": {
          "haircolor": {
            "type": "string"
          }
        }
      },
      "Man": {
        "properties": {
          "weight": {
            "type": "integer"
          }
        }
      },

      "Young": {
        "properties": {
          "schoolName": {
            "type": "string"
          }
        }
      },
      "Old": {
        "properties": {
          "employerName": {
            "type": "string"
          }
        }
      },

      "Data": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }

          },
          {
            "oneOf": [
              { "$ref": "#/components/schemas/Woman" },
              { "$ref": "#/components/schemas/Man" }
            ]
          },
          {
            "oneOf": [
              { "$ref": "#/components/schemas/Young" },
              { "$ref": "#/components/schemas/Old" }
            ]
          },
          {
            "properties": {
              "language": {
                "type": "string"
              }
            }
          }
        ]
      }
    }
  }
}

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 by reproducing the supplied OpenAPI 3.0 YAML or JSON example in ReDoc and inspect the rendering path for oneOf blocks nested inside allOf. Done means the switch buttons show the referenced sub-schema names instead of generic labels such as "object" or "object or object".

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
documentation, 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.