Skip to content

Does not detect nullable objects in some cases #379

@DronPascal

Description

@DronPascal

Detected unobvious plugin behavior:
For example (valid json)

[
   {
      "weight":{
         "imperial":"9 - 14",
         "metric":"4 - 6"
      },
      "image":{
       
      }
   },
   {
      "weight":{
         "imperial":"12 - 18",
         "metric":"5 - 8"
      },
      "image":{
         "id":"0SxW2SQ_S",
         "width":800,
         "height":1203,
         "url":"https://smth.jpg"
      }
   }
]

Plugin will generate 4 classes and this one will brake everything:

data class listItem(
    val image: Image,
    val weight: Weight
)

because Image must be nullable in this case.

Retrofit can handle this item without any error, but when I will try to [ map {} ] list of this items, map function will throw unchecked error or Unit idk(there are no any errors tho) just nothing on result if one of the items during mapping throws an error.
If this type were nullable I could immediately see where the error might occur with this particular json, the analysis of which I delegated to the plugin.

Metadata

Metadata

Assignees

Labels

L4Difficulty level 4 (Maximum is 9)enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions