-
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
Regression: Swagger CodeGen generates duplicate fields in child DTOs #12409
Comments
The issue occurs when a YAML DTO extends another DTO as follows where ================ YAML Definition ================
================ Output of Swagger CodeGen v2.3.1 ================
================ Output of Swagger CodeGen v2.4.41 ================
|
^ |
Regression v2.3.1 to v2.4.41
Problem
In v2.3.1 when Swagger CodeGen generates a child Java DTO class that inherits the fields of a parent class, the child class does not contain new fields. Instead it re-uses the existing fields inherited from the parent. This is the correct behaviour.
In v2.4.41 when Swagger CodeGen generates a child Java DTO class that inherits the fields of a parent class, the child class contains extra fields that duplicate the existing fields of the parent. This is incorrect behaviour. It causes JSON (de-)serializers to throw an exception due to duplicate fields having the same name.
Background
In OpenHAB one of its 450 odd third party integrations uses Swagger CodeGen to convert an API YAML file to respective Java API DTOs. We were using CodeGen v2.3.1 but we recently attempted to upgrade to CodeGen v2.4.41 -- but failed.
The API and the respective YAML have API fields name 'type' and CodeGen v2.3.1 creates them them in the DTO and applies the @SerializedName("type") annotation to them. When attemting to use CodeGen v2.4.41 we started seeing GSON exceptions that the DTO "declares multiple JSON fields named 'type'".
I am wondering what happened, and how to fix it?
See this openhab/openhab-addons#16779 for more..
The text was updated successfully, but these errors were encountered: