Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue where the parent schema has multiple discriminator mappings and each child schema also declares its all discriminator mapping #1360

Merged
merged 5 commits into from
Oct 17, 2024

Conversation

joelrosario
Copy link
Member

What:

The following schema was not handled correctly:

Vehicle:
  allOf:
    - ${'$'}ref: '#/components/schemas/VehicleType'
    - type: object
      properties:
        seatingCapacity:
          type: integer
  discriminator:
    propertyName: "type"
    mapping:
      "car": "#/components/schemas/Transmission"
      "bike": "#/components/schemas/SideCar"

Transmission:
  allOf:
    - ${'$'}ref: '#/components/schemas/Vehicle'
    - type: object
      requried:
        - gearType
      properties:
        gearType:
          type: string
  discriminator:
    propertyName: "type"
    mapping:
      "car": "#/components/schemas/Transmission"

Note that car is declared both in the parent Vehicle schema and the child Transmission schema.

Checklist:

…a top level allOf and one of them is repeated in a child, the discriminator mechanism breaks down
@joelrosario joelrosario self-assigned this Oct 15, 2024
@joelrosario joelrosario force-pushed the discriminator_duplicated_in_extension branch from 5fc735f to 17da91e Compare October 16, 2024 12:11
@joelrosario joelrosario changed the title Issue when discriminator is declared in both parent and child schema Resolve Issue where the parent schema has multiple discriminator mappings and each child schema also declares its all discriminator mapping Oct 16, 2024
@joelrosario joelrosario changed the title Resolve Issue where the parent schema has multiple discriminator mappings and each child schema also declares its all discriminator mapping Resolve issue where the parent schema has multiple discriminator mappings and each child schema also declares its all discriminator mapping Oct 16, 2024
@joelrosario joelrosario merged commit 6d505f7 into main Oct 17, 2024
2 checks passed
@joelrosario joelrosario deleted the discriminator_duplicated_in_extension branch October 17, 2024 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant