Skip to content

Bad title of oneOf-Switch button in allOf #995

@jens-duttke

Description

@jens-duttke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    openapiQuestions about specification, validity, and edge cases

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions