Marwes / schemafy

Crate for generating rust types from a json schema
MIT License
242 stars 51 forks source link

Skip serializing non-required `None` value #55

Closed bgilbert closed 2 years ago

bgilbert commented 2 years ago

Currently we correctly skip serialization of properties with None values if we've synthesized the Option<T> wrapper because the property is not required. However, when the property is not required and it's already typed Option<T> because it's defined as "type": ["T", "null"], we were not skipping serialization when its value is None. Do so.

Also add a test for required/optional arrays, and extend the OptionType test to cover required fields.

Marwes commented 2 years ago

LGTM, thanks!