Forum Discussion

Numerlor's avatar
Numerlor
Frequent Visitor
2 years ago

Discriminator property disappears from example when mapping is added

Hi, I'm trying to get the discriminator property to show up in examples when using oneOf, but it disappears when I add a custom mapping under discriminator in the object that has the oneOf.

This is what the document looks like

Spoiler
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'