Ask a Question

Discriminator property disappears from example when mapping is added

Numerlor
Frequent Visitor

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'

 

1 REPLY 1
ponelat
Staff

hi @Numerlor ,

 

That appears to be a bug on SwaggerUI, feel free to log a bug there...  https://github.com/swagger-api/swagger-ui/issues/new

cancel
Showing results for 
Search instead for 
Did you mean: