Open maloef opened 4 years ago
@maloef thanks for reporting this issue. would you like to implement a fix for this?
@maloef can you also give the latest stable version (v4.1.3) a try just to ensure the bug is still there?
Also if I remember correctly, you may want to try marking the property as nullable
to see if that helps.
Thanks for your prompt replies! The problem still exists in version 4.1.3.
I tried marking the property as nullable and adding the dependency
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.0</version>
</dependency>
Then this is generated:
private JsonNullable<List<Foo>> foos = JsonNullable.<List<Foo>>undefined();
This is not what we would like to have. We would prefer plain old Java classes.
Some time ago, there was a change so that Java lists are instantiated instead of null.
We reverted that with: https://github.com/OpenAPITools/openapi-generator/pull/3615
See the discussion: https://github.com/OpenAPITools/openapi-generator/issues/1861
The idea behind jackson-databind-nullable
is that you need to track if a value is set to null
explicitly or not.
This was introduced by @bkabrda in https://github.com/OpenAPITools/openapi-generator/pull/3474, If I remember well you can disable this behavior, but I am not sure.
Hello @jmini Thank you for the links! Now I understand that this behavior makes sense in some cases, but not in others.
Some time ago, there was a change so that Java lists are instantiated instead of null:
instead of
This was the change that provided instantiated lists: https://github.com/OpenAPITools/openapi-generator/pull/1683
It worked in version 4.0.0 and 4.1.0, but it no longer works in version 4.1.1 and 4.1.2.