Skip to content

Discriminator property in component disappears from component when mapping is used under discriminator #8336

Open
@Numerlor

Description

@Numerlor

When I have the discriminator property explicitly listed on the components that are under a oneOf, it disappears when mapping is used under discriminator.

For example with the following document, the example is

{
  "prop2": "string"
}

but with mapping removed it changes into

{
  "prop2": "string",
  "type": "string"
}
OpenAPI document
openapi: 3.0.3
info:
  title: ''
  version: 0.0.0
paths:
  /test/:
    post:
      operationId: test_create
      tags:
        - events
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TestPolymorphic'
      responses:
        '200':
          description: ''
components:
  schemas:
    Test1:
      type: object
      properties:
        prop1:
          type: string
        type:
          type: string
      required:
        - prop1
        - type
        
    Test2:
      type: object
      properties:
        prop2:
          type: string
        type:
          type: string
      required:
        - prop2
        - type
        

    TestPolymorphic:
      oneOf:
        - $ref: '#/components/schemas/Test2'
        - $ref: '#/components/schemas/Test1'
      discriminator:
        propertyName: type
        mapping:
          Test2: '#/components/schemas/Test2'
          Test1: '#/components/schemas/Test1'

Activity

Laikos38

Laikos38 commented on Jul 27, 2023

@Laikos38

Hi! Did you find a solution to this?

Numerlor

Numerlor commented on Jul 28, 2023

@Numerlor
Author

Hi! Did you find a solution to this?

Just went with Redoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @Numerlor@Laikos38

      Issue actions

        Discriminator property in component disappears from component when mapping is used under discriminator · Issue #8336 · swagger-api/swagger-ui