Reputation: 73
Problem: When I generate a class with the openAPI code generator properties with a List type are initialized right away as an empty ArrayList. I want to remove this initialization, so that this property can be null. How can I do this in the openAPI specification?
Use-Case: For my merge-patch operation, I need to distinguish between giving an empty list as parameter or not specifying the parameter at all. I would expect that I get an empty list when the parameter is given but contains an empty List and null if the parameter is not given.
Upvotes: 7
Views: 6056
Reputation: 314
The option containerDefaultToNull
let you choose if null
or empty (List, Map), see the doc.
But it seems the generated code/parser won't distinguish a null
or empty input. I'm not sure about it, you should analyse the generated code for that.
Upvotes: 7