Skip to content

[BUG] [CORE] Composed Schema discriminator map incorrect with oneOf/anyOf #4904

@spacether

Description

@spacether

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When defining the below Apple.. and Banana.. oneOf models, the discriminator in FruitRequiredDesc model does not include the mapping to the children, even though they contain the required fruitType property

openapi-generator version

latest master branch

OpenAPI declaration file content or url
    FruitType:
      properties:
        fruitType:
          type: string
      required:
      - fruitType
    FruitRequiredDesc:
      oneOf:
        - $ref: '#/components/schemas/AppleRequiredDesc'
        - $ref: '#/components/schemas/BananaRequiredDesc'
      discriminator:
        propertyName: fruitType
    AppleRequiredDesc:
      type: object
      required:
        - seeds
      properties:
        seeds:
          type: integer
      allOf:
        - $ref: '#/components/schemas/FruitType'
    BananaRequiredDesc:
      type: object
      required:
        - length
      properties:
        length:
          type: integer
      allOf:
        - $ref: '#/components/schemas/FruitType'
Command line used for generation

generate any client with the above input spec
specifically I am working in python

Steps to reproduce

generate any client with the above input spec
inspect the discriminator map and notice that it is empty

Related issues/PRs

#2058

Suggest a fix

I will work on one

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions