openhab-addons: [swagger-codegen] IllegalArgumentException TadoModeTerminationCondition: declares multiple JSON fields named 'type'
Current Behavior
An error occurs when initializing or interacting with the tado addon in version 4.2.0 M3.
2024-05-20 16:16:58.863 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.IllegalArgumentException: Class org.openhab.binding.tado.internal.api.model.TadoModeTerminationCondition declares multiple JSON fields named 'type'; conflict is caused by fields org.openhab.binding.tado.internal.api.model.TadoMo
deTerminationCondition#type and org.openhab.binding.tado.internal.api.model.OverlayTerminationCondition#type
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:302) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) ~[?:?]
at com.google.gson.Gson.getDelegateAdapter(Gson.java:652) ~[?:?]
at org.openhab.binding.tado.internal.api.RuntimeTypeAdapterFactory.create(RuntimeTypeAdapterFactory.java:60) ~[?:?]
at com.google.gson.Gson.getAdapter(Gson.java:556) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) ~[?:?]
at com.google.gson.Gson.getAdapter(Gson.java:556) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) ~[?:?]
at com.google.gson.Gson.getAdapter(Gson.java:556) ~[?:?]
at com.google.gson.Gson.fromJson(Gson.java:1226) ~[?:?]
at com.google.gson.Gson.fromJson(Gson.java:1137) ~[?:?]
at com.google.gson.Gson.fromJson(Gson.java:1047) ~[?:?]
at com.google.gson.Gson.fromJson(Gson.java:1014) ~[?:?]
at org.openhab.binding.tado.internal.api.client.HomeApi.showZoneState(HomeApi.java:529) ~[?:?]
at org.openhab.binding.tado.internal.handler.TadoZoneHandler.getZoneState(TadoZoneHandler.java:129) ~[?:?]
at org.openhab.binding.tado.internal.handler.TadoZoneHandler.updateZoneState(TadoZoneHandler.java:325) ~[?:?]
at org.openhab.binding.tado.internal.handler.TadoZoneHandler$1.run(TadoZoneHandler.java:420) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:840) [?:?]
Environment
- Version used: openHAB 4.2.0-M3, Add-on 4.2.0-M3
- Operating System and version: Ubuntu server, 5.15.0-1055-raspi, openhabian
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (11 by maintainers)
@holgerfriedrich I suppose the “only” risk is if the Swagger Codegen v2.3.1 is no longer downloadable and we know that later versions don’t work. I am inclined to static copy the java files into OH so that we have everything in house.
There’s always the option to stop using the generator. Just copy the generated code that works and commit it, then remove the generator-step. From then on, maintain the DTOs manually.
I’ve initially created the generator to simplify API integration in OH in general and without introducing extra dependencies. But as far as I know, it’s still only used in the tado integration and never found a wider acceptance.
So I would suggest, get rid of the unicorn. As I’m not using OH anymore for a long time now, I will also not spend time keeping the generator up to date. So this step makes most likely a lot of sense, regardless of the issue.
Hopefully my point of view helped at least a little bit.
https://community.smartbear.com/discussions/swaggerostools/swagger-codegen-declares-multiple-json-fields-named-type/265061
@lolodomo / @dandjo even though this issue has been closed I am keeping the above suggestion in my mind. The problem is that it is not so easy to fix. The problem is that the Tado Cloud API does actually use JSON payloads with fields named ‘type’ and it seems the latest version of Swagger correctly parses the Tado YAML and generates DTOs for the API payloads with API related fields named ‘type’ annotated with '@SerializedName(“type”) but it apparently generates extra fields with the same '@SerializedName(“type”) annotation. I am not sure why that would happen with the new Swagger version. There may hopefully be a compatibility switch to turn off that new behaviour (i.e. make the new Swagger version behave like the older version), but I would need to study Swagger in my spare time. In the meantime the way to make Swagger behave like the older version is to – well – use the older version…