So SeparatorConfig has two properties, both of which have default values.
Elsewhere in another object I have a field of type SeparatorConfig, and I'd like to make the entire field optional such that it defaults to an object with the correct default field values as defined above.
Overall this would make specifying default values for objects throughout a schema significantly easier.
The current alternatives are to either specify all the default field values at every level, duplicating a lot of default values (error prone), or not specifying defaults in the schema and manually constructing default structs in code when properties are None (cumbersome).
Let's say I have the following object definition in my schema:
So
SeparatorConfig
has two properties, both of which have default values.Elsewhere in another object I have a field of type
SeparatorConfig
, and I'd like to make the entire field optional such that it defaults to an object with the correct default field values as defined above.I could in theory do the following:
However the resulting generated code which produces this default value is:
Which produces:
Rather than the desired default:
A better implementation for creating the default
SeparatorConfig
struct would be to use the existing builders you already generate:We would also have to use the builder functions for defaults which specify only some properties:
Could produce:
rather than the current:
Overall this would make specifying default values for objects throughout a schema significantly easier.
The current alternatives are to either specify all the default field values at every level, duplicating a lot of default values (error prone), or not specifying defaults in the schema and manually constructing default structs in code when properties are
None
(cumbersome).