Skip to content

[BUG][KOTLIN] Polymorphism not workingΒ #18167

@grassehh

Description

@grassehh

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Hi, I'm not certain is this is a bug or a feature since a few things seems to works correctly.
When using polymorphism with discriminator exactly as documented on OpenAPI 3.0 specifications, the following of the generated code is incorrect:

  • The parent interface contains all childs properties
  • The child classes do not implement the parent interface
  • The child classes do not have the override keyword on parent interface discriminator property

Note: The same issue is noticeable when using kotlin-spring generator

openapi-generator version

7.4.0

OpenAPI declaration file content or url

https://github.com/grassehh/openapi-generator-experiments/blob/main/openapi.yaml

Generation Details

Checkout this repository and build using gradle build.
The generated code is in the build directory.

Steps to reproduce

Simply generate the Kotlin code as explained above then read the generated code in build directory.

Related issues/PRs
Suggest a fix

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