Replies: 1 comment
-
|
It suffices to use a default value: @Serializable
data class PatchData(
val required: Int,
val someNullableProperty: Option<Int?> = None,
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not sure this is actually possible so asking as a question here but given the following:
Is it possible to have
someNullablePropertyto only beNoneif the field is missing from the json butSome(null)if the field is set tonull? E.g.{ "required": 1 }becomesPatchData(required: 1, someNullableProperty: None){ "required": 1, "someNullableProperty": null }becomesPatchData(required: 1, someNullableProperty: Some(null))This is to deal with PATCH requests where the field missing represents something different than when the field is null.
I know this is probably counter to the ideal of arrow but figured I'd ask. Also would be interesting to hear how others may represent/handle this. Thanks
Beta Was this translation helpful? Give feedback.
All reactions