Skip to content

OpenAPI 3 with discriminator & mapping fields #1076

Open
@gigaga

Description

@gigaga

Hi,

Firstly, congratulations for your tool. It is really the best viewer that I could have used!

From redoc v2.0.0-rc.18, I have a problem with discriminator & mapping fields of OpenAPI 3
Indeed, below, we can see my screenshot from the following specs file:

openapi: 3.0.0

########## INFO ##########
info:
  title: Test
  description: Specifications of test bounded context
  version: 1.0.0

paths:
  /pet:
    put:
      tags:
      - Pet
      description: Test
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Pet"
        description: Capture that has to be applied to transaction
      responses:
        "200":
          description: The transaction captured.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      type: object
      required:
      - pet_type
      properties:
        pet_type:
          type: string
      discriminator:
        propertyName: pet_type
        mapping:
          dog: "Dog"
          cat: "Cat"
          lizard: "Lizard"
    Dog:
      allOf:
      - $ref: "#/components/schemas/Pet"
      - type: object
        # all other properties specific to a `Dog`
        properties:
          bark:
            type: string
    Cat:
      allOf:
      - $ref: "#/components/schemas/Pet"
      - type: object
        # all other properties specific to a `Cat`
        properties:
          name:
            type: string
    Lizard:
      allOf:
      - $ref: "#/components/schemas/Pet"
      - type: object
        # all other properties specific to a `Lizard`
        properties:
          lovesRocks:
            type: boolean

Capture

Metadata

Metadata

Assignees

No one assigned

    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