google / google/built_value.dart
Support serializing null on a per field basis - nullable vs required
- Dominant language
- Dart
- Stars
- 886
- Forks
- 195
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 4
Description
There is an OpenApi generator which generates built_value/dio based classes for OpenApi specifications.
OAS 3.0 and also [JSON schema spec](http://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5.3) support the combination of fields being required but nullable - meaning they have are required in the json output but may be `null`. This combination can currently not be achieved with built_value on a field level.
I know that there is a (now removed on master) option `@BuiltValueSerializer(serializeNulls: true)` but this only works for all fields of the same type.
Is it possible to add a similar option on a per field basis?
```
@nullable
@BuiltValueField(serializeNulls: true)
String foo;
```
or
```
@BuiltValueField(serializeNulls: true)
String? foo;
```
See https://github.com/OpenAPITools/openapi-generator/issues/5411
Contributor guide
Assessment
This issue has not been assessed yet.