Skip to content

[Bug] Backward compatibility check fails on reordered discriminator mappings #886

Description

@OllieKosh

Ran into a compatibility issue, which I believe is a false positive. I have one polymorphic schema, that maps to two different property names. The backwards compatibility check fails if the mappings are re-ordered.

This should not be failing, because neither discriminator names nor the mapping changed.

For example, the following 2 should be considered compatible, but are not. Assume the actual schemas are identical. Schema A is mapped to a-type and z-type which are present in both mappings, but are ordered differently.

             schema:
               oneOf:
                 - $ref: '#/components/schemas/A'
                 - $ref: '#/components/schemas/B'
               discriminator:
                 propertyName: realtype
                 mapping:
                   z-type: '#/components/schemas/A'
                   a-type: '#/components/schemas/A'
                   b-type: '#/components/schemas/B'

and

              schema:
                oneOf:
                  - $ref: '#/components/schemas/A'
                  - $ref: '#/components/schemas/B'
                discriminator:
                  propertyName: realtype
                  mapping:
                    a-type: '#/components/schemas/A'
                    z-type: '#/components/schemas/A'
                    b-type: '#/components/schemas/B'

I was able to reproduce this in this repo by adding a test to OneOfDiffTest with the above as an example (based on oneOf_discriminator-missing_1.yaml).

  @Test
  public void testOneOfDiscrimitatorDifferentOrder() {
    assertOpenApiAreEquals(OPENAPI_DOC11, OPENAPI_DOC12);
  }

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions