Generalize the option to always output optional fields that are set to the default value (~field : ...
syntax)
#354
Labels
enhancement
feature request
Big and small feature requests
target:python
Issues related to the Python backend (atdpy)
target:typescript
Issues related to the TypeScript backend (atdts)
To reduce breakage when an optional record field becomes required, an implementation of an ATD interface can output optional fields even though they have the default value. It allows future implementations that read old data or data produced by an old implementation in which the field used to be optional.
This applies to the
~
syntax for optional fields with a default but not to the?
syntax which are optional fields without a default or equivalently whose default is null/None. The main use of~
is for lists and booleans where the default is obvious:A valid JSON representation for a record of type
t
is{}
. It has the advantage of being compact. Forcing the output of default values would instead produce the following JSON object:Such an option is already supported by atdgen in the form of
-j-defaults
. There is demand for having it across all backends (especially Python and TypeScript). Alternatively, this can be made the default or the only behavior.The text was updated successfully, but these errors were encountered: