elements icon indicating copy to clipboard operation
elements copied to clipboard

Title missing for dropdown when rendering double oneOf/allOf

Open Thomasdezeeuw opened this issue 3 years ago • 0 comments

Context

When using oneOf using a schemas that themselves have a allOf Elements uses "any (one of)" as title for the dropdown to select the schema options instead of the schema's title, see the image attached at the current behaviour section.

Current Behavior

Screenshot 2022-07-05 at 13 00 33

Expected Behavior

I would expect the title of the schema would be used instead of "any", for example:

Screenshot 2022-07-05 at 13 06 01

Steps to Reproduce

The following spec should reproduce the problem:

openapi: 3.1.0
info:
  title: Test
  description: Test
  version: "1.0.0"
paths:
  /path:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Schema'
        required: true
      responses:
        '200':
          description: OK.
components:
  schemas:
    Schema:
      title: Schema
      type: object
      required:
        - kind
      oneOf:
        - $ref: '#/components/schemas/Kind1'
        - $ref: '#/components/schemas/Kind2'
      discriminator:
        propertyName: kind
        mapping:
          kind1: '#/components/schemas/Kind1'
          kind2: '#/components/schemas/Kind2'
    Kind1:
      title: Kind1
      type: object
      allOf:
        - oneOf:
            - $ref: '#/components/schemas/Kind1Part1'
            - allOf:
                - properties:
                    kind:
                      type: string
                      enum:
                        - kind1
                - $ref: '#/components/schemas/Ref'
        - $ref: '#/components/schemas/Kind1Part2'
    Kind2:
      title: Kind2
      type: object
      allOf:
        - oneOf:
            - $ref: '#/components/schemas/Kind2Part1'
            - allOf:
                - properties:
                    kind:
                      type: string
                      enum:
                        - kind2
                - $ref: '#/components/schemas/Ref'
        - $ref: '#/components/schemas/Kind2Part2'
    Kind1Part1:
      title: Kind1Part1
      type: object
      properties:
        kind:
          type: string
          enum:
            - kind1
        kind1_field1:
          description: Field1
          type: string
    Kind2Part1:
      title: Kind2Part1
      type: object
      properties:
        kind:
          type: string
          enum:
            - kind2
        project_id:
          description: Field 1
          type: string
    Kind1Part2:
      title: Kind1Part2
      type: object
      properties:
        kind1_field2:
          description: Field 2
          type: string
    Kind2Part2:
      title: Kind2Part2
      type: object
      properties:
        kind2_field2:
          description: Field2
          type: string
    Ref:
      title: Ref
      type: object
      properties:
        ref:
          type: string
          format: uuid

Thomasdezeeuw avatar Jul 05 '22 11:07 Thomasdezeeuw