-
Notifications
You must be signed in to change notification settings - Fork 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
discriminator generated in both base and child #3829
Comments
@AlexanderN am I understanding correctly that that the Java client does not have the issue and only ObjC, Swift and C# client has the issue? |
Correct, I've attached the Java client generated code for the yaml in question which does what you will expect. Base properties are not copied to the child class. On the other hand, the Objective-C does duplicate the properties Possible workaround would be to mark the child properties as dynamic to avoid the compilation warnings produced by the current output. Not having the parent properties would probably be best. The C# client generation also copies the properties found in the parent class |
I've tested Swift Client and it does not use inherit the Pet class, it uses composition instead. So, it should not be part of this issue. |
languages that support inheritance should have useInheritance=true. I guess it should be set for Obj-C and C# codegens. |
As you mentioned, I see some references to useInheritance One would assume to see this in the Java client though. |
Oh, my mistake ! It's supportsInheritance I was talking about ! |
In that case, I wonder if the fix is as simple to add the code below to the clients in question.
|
I would say just |
@cbornet |
You should regenerate the samples. There are scripts for this in the ./bin directory. |
@cbornet
Child class no longer copies the className property
All in all, changing ObjcClientCodegen.java appears to do the work which makes me wonder why it it was false. It's my understanding that using allOf along with a discriminator is an indication of inheritance for code-gen.
|
Description
Should the discriminator property be also a property of the child class even if it is already in the base class?
Swagger-codegen version
2.2
Swagger declaration file content or url
ticket.yaml.txt
Command line used for generation
Objective-C and C# client generators generate the petType in the base and child class. Thus generating compilation warnings. OTOH, the Java generator does not duplicate the property.
Steps to reproduce
Simply generate C# or Objective-C client code for the YAML aforementioned
Related issues
Suggest a Fix
Child classes should not duplicate properties found in the base class. The work around is to only define the discriminator in the base class and then copy/paste the property on each child class.
The text was updated successfully, but these errors were encountered: