Forum Discussion
HI hugomario ,
I'm suffering the same issue with AlexeyNezhdanov , the base class in my yaml file was generated to "Object" in the polumorphism (using swagger-codegen-3.016).
The link in your reply seems not working anymore, do we have a fix for this issue ?
hello qiandj, can you try with latest release? this should have been addressed, in case it's still present, please let me know and i work on it asap.
- AlexeyNezhdanov5 years agoOccasional Contributor
Hi hugomario .
Sorry, I might have missed your previous update to this ticket, otherwise I would have tested this long ago.
I have tried the following (same YAML as in the OP):
1) java -jar openapi-generator-cli-4.3.0.jar generate -i openapi.yaml -g jaxrs-spec && mvn clean install
Result: COMPILATION ERROR.
Besides, when looking at the generated models the module org.openapitools.model.OneOfDogCat is imported but doesn't seem to be generated (at all).2) -g jaxrs-resteasy-eap
Same problem.
3) -g java-undertow-server
Same problem. The models are not referenced from the controller, however they reference each other and OneOfDogCat is still missing
4) -g java-inflector
Same problem.
5) -g java
This is a client build (all the previous were server ones) and it demonstrates the same problem - OneOfDogCat is used but is not generated.----------------- UPDATE ----------------
I have re-read my original post in this thread and it seems that there is another file that is not generated now: AllPetsResponse.Sorry, I'm taking this back. The file is indeed not generated, but it is also not used so that's fine.
- AlexeyNezhdanov5 years agoOccasional Contributor
(re-posting because my previous post seems to be gone).
Looking further at the generated files I notice that this does not seem to be solved in the extensible way.Original state (at the time of opening this ticket):
public class SinglePetResponse { private @Valid Object pet = null; }Current state (ignoring the fact the OneOfDogCat is not generated):
public class SinglePetResponse { private @Valid OneOfDogCat pet = null; }Desired state:
public abstract class Pet { } public class SinglePetResponse { private @Valid Pet pet = null; }We can argue about the Pet class being abstract, of course, but the pet field being of type Pet and not something else is crucial. Otherwise if I extend my API later by adding a type Turtle, my existing code will break because some classes would be renamed.
- hugomario5 years ago
Staff
Thanks AlexeyNezhdanov
For reply, i'll work on the issues you got, hopefully i expect to have an update this friday