Skip to content

Issue with dropdown options for discriminated schema in request body #1288

Open
@zimmyg

Description

@zimmyg

When defining a schema for a request body that uses oneOf and a discriminator with a mapping, the dropdowns show the option for the base item as well, which is incorrect and should not be defined as an option.

redoc_issue

Simplified Example:

openapi: 3.0.0
info:
  title: test
  version: 1.0.0
    
paths:
  '/test/{testId}':
    patch:
      summary: Broken test
      operationId: updateSchedule
      parameters:
        - $ref: '#/components/parameters/TestIdPath'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/TestRequestBody'
      responses:
        '200':
          $ref: '#/components/responses/TestModel'
          
          
components:
  parameters:
    TestIdPath:
      in: path
      required: true
      name: testId
      schema:
        type: integer
  
  schemas:
    TestRequestBody:
      allOf:
        - $ref: '#/components/schemas/TestModel'
        - description: Additional description
    
    BaseTestModel:
      type: object
      properties:
        baseProperty:
            type: string
    
    SubTestModel1:
      allOf:
        - $ref: '#/components/schemas/BaseTestModel'
        - type: object
          properties:
            subProp1:
              type: string
      
    SubTestModel2:
      allOf:
        - $ref: '#/components/schemas/BaseTestModel'
        - type: object
          properties:
            subProp2:
              type: string
    
    TestModel:
      oneOf:
        - $ref: '#/components/schemas/SubTestModel1'
        - $ref: '#/components/schemas/SubTestModel2'
      discriminator:
        propertyName: baseProperty
        mapping:
          ONE: '#/components/schemas/SubTestModel1'
          TWO: '#/components/schemas/SubTestModel2'
  
  
  responses:
    TestModel:
      description: A test model
      content:
        application/vnd.yellowfin.api-v1+json:
          schema:
            $ref: '#/components/schemas/TestModel'

Metadata

Metadata

Assignees

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