-
Notifications
You must be signed in to change notification settings - Fork 6k
[Java] swagger-codegen-maven-plugin does not use inheritance (extends) in generated classes #9693
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
Comments
try with add the discriminator: type
|
@chiochuan Thanks, that works as a workaround. Although it's currently not necessary online, or for other languages, like TypeScript. Also, I think the solution is a bit surprising, given what the docs for the OpenAPI Specification Version 2.0 specify for the
And that's precisely not how it's used in the workaround: Neither is In other words, I'm a bit confused as to why this actually does work at all... ;-) |
If I don't have a discriminator property, how do I set that up? I was relying on the old generation that used extends and honestly prefer that behavior over the duplication of fields. I didn't want (nor can, to be honest) alter the model attributes just for having that. |
@HugoMario With this fix I started getting "inheritance" instead of "composition" in the models generated unexpectedly(there's no discriminator attribute specified) and as a result in runtime the de-serialization fails with "missing discriminator field <>" error. |
Description
In our
swagger.yaml
file, we have a definitionCat
that usesallOf
to include all properties ofPet
.The expectation is that when generating Java sources, we get
This works when using the Swagger Editor.
When using swagger-codegen-maven-plugin with no
configOptions
set, we get the following:Cat
implements all ofPet
's properties itself, instead of extending it.Swagger-codegen version
swagger-codegen-maven-plugin version 2.4.8
Swagger declaration file content or url
Command line used for generation
mvn clean generate-sources
Steps to reproduce
swagger.yaml
tosrc/main/resources/
build
block topom.xml
:Related issues/PRs
#6148 seems to report that this is not working online (which it currently is for the test data provided here) but instead offline (which it isn't for the data here with the latest stable build), so this is potentially a regression.
Suggest a fix/enhancement
n/a
The text was updated successfully, but these errors were encountered: