openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [JAVA] [Micronaut] - Using inheritance results in superclass having all fields from subclasses

Open KangoV opened this issue 1 year ago • 2 comments

Bug Report Checklist

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

When using inheritance (discriminator), the generated subclasses gains fields in their constructors for other subclasses fields. Also, the superclass, gets all the fields of all the subclasses combined. Some getters are also duplicated resulting in compile errors.

It seems all the fields are merged together.

openapi-generator version

6.11.0

OpenAPI declaration file content or url

https://gist.github.com/KangoV/ad36a85420f7c8187a208e09fe9d4242

Generation Details

Using Micronaut Gradle plugin:

    openapi {
        version = "6.11.0"
        server(file(layout.buildDirectory.file("tmp/$specFile"))) {
            apiPackageName = basePackage + ".api"
            modelPackageName = basePackage + ".api.model"
            useOptional = true
            useReactive = false
        }
    }

Generates the superclass/subclass:

https://gist.github.com/KangoV/8a62886376207e281e8b0fedd008a24d

KangoV avatar Jun 30 '24 01:06 KangoV

@KangoV could you move it to right repo? Here: https://github.com/micronaut-projects/micronaut-openapi

altro3 avatar Aug 25 '24 13:08 altro3

@KangoV fixed it here: https://github.com/micronaut-projects/micronaut-openapi/pull/1732

altro3 avatar Aug 26 '24 11:08 altro3