-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[Kotlin][allOf] Generated Code, Data class extends Data class #6080
Comments
This happens also in java models since version 4.3.0
with 4.2.3 following result is generated
|
@wrssmi I believe the result is fine in Java. Except i don't fully understand what you mean. |
i only want the behavior of extending models if I define it with discriminator
than this is ok:
As I mentioned with generator 4.2.3 it works in that way |
@wrssmi that's a bug (regression) in 4.3.0 and we've fixed it in the master. Please give it a try and let us know how it goes. |
4.3.1-SNAPSHOT is working fine for my regression tests! |
This issue is related to Kotlin codegen extending data class. As @donpaul120 mentioned, data class cannot be extended in Kotlin. Looks like this discussion got hijaked into a Java codegen issue. |
@prabu-ramaraj exactly, it was forcefully hijacked. I mean you could create an issue relating to Java and that's fine but the codegen issue relating to java that @wrssmi talks about doesn't relate to what the issue refers to in Kotlin. They are not even close. |
give it a try with 4.3.1-SNAPSHOT related fix |
@wrssmi - Yes, the latest Snapshot fixes this issue in Kotlin as well. This is great. When can we expect the snaphsot to be published? I think it's supposed to be published 2 weeks back right? |
use 4.2.3. in that version it works also.
prabu-ramaraj <[email protected]> schrieb am Mo. 4. Mai 2020 um
18:11:
@wrssmi <https://github.com/wrssmi> - Yes, the latest Snapshot fixes this
issue in Kotlin as well. This is great. When can we expect the snaphsot to
be published? I think it's supposed to be published 2 weeks back right?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6080 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMWIELXSUH2I3PQIQLDHE3RP3SLFANCNFSM4MSJ57GA>
.
--
lG Michael
|
@wrssmi - I tested all the way down to 4.2.1, I am still seeing this issue in older versions. I am using Gradle plugin. In 4.2.1, "override" is gone, but still it is extending from parent data class. I can't go below 4.2.1 without updating my build script. Is there anyway to get an ETA for 4.3.1 release? I have downloaded the Gradle plugin JAR for 4.3.1-SNAPSHOT version. I will use this for my development now |
@donpaul120 issue still exists in 5.2.0 |
@wing328: Any plans for fixing this if you have multiple layer inheritance?
This generates:
|
I guess
|
@tormodatt for example, but it will prevent system from creation of actual |
@asm0dey: But you could create a
And when creating an *Impl instance having an understanding that these instances have to be created with discriminator (petType) without the impl part, i.e. "dog" and not "dogImpl":
Then, when receiving
you could deserialize it to a |
@torsjens yes, you're right. If the backend will support such behaviour - it's a working solution! |
This is working in 7.0.1. Child data class does not extends the Parent data class. If you add discriminator to Parent it becomes an Interface and Child data class extends it. Disclaimer: I didn't test with the provided spec but I had a very similar one. |
FYI. One can use openapi normalizer (rule: REF_AS_PARENT_IN_ALLOF ) to consider $ref as parent without using discriminator. |
Thanks for the info, very useful! Should this issue be closed? |
This thread should be reopened (or created new one instead) in order to include the solution proposed by @torsjens. It would be great to generate an interface and implementation for each model. This would allow upcasting to any ancestor class. |
The above spec generates:
In Kotlin it's impossible for a data class to extend a data class.
The text was updated successfully, but these errors were encountered: