OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.58k stars 6.52k forks source link

[BUG][Spring] fields are duplicated in parallel subclasses if schema-mapping is used #19044

Open arandth opened 3 months ago

arandth commented 3 months ago

Bug Report Checklist

Description

My model uses inheritence. I have a base-class "DemoRoot" which has two derived subclasses "DemoSubclass1" and "DemoSubclass2". These classes have one common field "type" (the discriminator) and one specific field - "unwantedProperty" in "DemoSubclass1" and "subclass2_property" for "DemoSubclass2". However, my real API has more fields and classes, but I was able to track it down to a minimum example which is also attached to the problem report. So far everything is right. The problem arises as I need to use schemaMapping as I need a hand-written version of DemoSubclass1. Now - as required - no java-File for DemoSubclass1 is produced, but suddenly you find all the fields on DemoSubclass1 (which is "unwantedProperty") in all the paralled subclasses (DemoSubclass2 in my case). This is definitely wrong. I tried to remove the schema-mapping rule from the pom-file, then the code is right. (But as I said: I definitly need schema-mapping.)

openapi-generator version

version 7.6.0

OpenAPI declaration file content or url
Generation Details

problem-demo.tar.gz

arandth commented 2 months ago

Hi Openapi-generator community is there anybody who can analyse (and correct) the problem? I just retried with version 7.7.0, the problem still persists. Thanks a lot, Thomas