[Java] [Spring] provide optionals also for model fields
Created by: atomfrede
Description
Follow up of discussion with @cbornet https://twitter.com/atomfrede/status/1051787697201827840
When setting useOptional=true
only query parameter are affected. All model fields are are not affected.
Why is that useful? When using json-patch-merge a field not send is different from a value explicitly set to null. Where in the first case the field should not be updated in the second case it means the field should be removed. Currently this is not possible as both a not provided field and field set to null will result in the field being null. When the model fields are optional a field being null would mean it was not send and an empty optional would mean it was send but set to null.
Example
-
{a:b,c:d}
-- Patch/Merge{c:null}
-->{a:b}
(c is removed) -
{a:b,c:d}
-- Patch/Merge{c:""}
-->{a:b,c:""}
(c is set to emtpy string)
openapi-generator version
3.3.0
Related issues/PRs
Couldn't find any.
Suggest a fix/enhancement
Optional fields (or maybe optional fields when using patch) and setting useOptional=true
should make a difference between value not set (==null) and value set to null (==empty optional) to support json-patch-merge