Skip to content

[Question]: Ref handling in discriminator mappings doesn't allow different discriminator keys to map to the same entity? #2222

@IgorMaj

Description

@IgorMaj

Question

Hello, I'm using your library as part of the following component (openapi-generator), and I've already posted an issue here. In the snippet below, you can see what I'm trying to do. I'm trying to map different discriminator property values to the same entity. However, it results in an error.

Affected Version

2.0.30 (at least), seems to be introduced here.

I'm using 2.0.30

Context

      responses:
        '200':
          description: "List of all the objects."
          content:
            application/json:
              schema:
                type: array
                items:
                  oneOf:
                    - $ref: '#/components/schemas/TypeA'
                    - $ref: '#/components/schemas/TypeB'
                  discriminator:
                    propertyName: discriminatorProperty
                    mapping:
                      ONE: '#/components/schemas/TypeA'
                      TWO: '#/components/schemas/TypeB'
                      THREE: '#/components/schemas/TypeB'
                      FOUR: '#/components/schemas/TypeB'
                      FIVE: '#/components/schemas/TypeB'

Additional Details

This is the error:
java.lang.IllegalStateException: Duplicate key #/components/schemas/TypeB (attempted merging values TWO and THREE)

Checklist

  • [ y] I have searched the existing issues and documentation before asking.
  • [ y] I have provided enough information for others to understand my question.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions