smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

Support more flexible explicit defaults

Open kubukoz opened this issue 1 year ago • 2 comments

Currently, explicit defaults are "all or nothing". Some users (myself included) might want to skip nulls, or skip empty collections - it would be great to have this configurable, e.g. as a Schema[_] => Boolean function rather than just Boolean.

One problem I see with this is that anything currently implemented with a SchemaVisitor won't have the original Schema[A], but rather its pieces that may be composed into a Schema again.

kubukoz avatar Feb 08 '24 19:02 kubukoz

current thinking is having something like this

.withDefaultEncoding(
  f: [A] => Field[_, A] => A => Boolean
)

then you can e.g. check if the field has an optional schema, and based on that + the value decide to e.g. write Some(defaultValue) but not None.

kubukoz avatar Feb 19 '25 16:02 kubukoz

Okay, let's try it.

Baccata avatar Feb 20 '25 08:02 Baccata

done in #1652 #1662 and released in 0.18.31.

kubukoz avatar Mar 21 '25 13:03 kubukoz