You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that the default for the my_struct2 property has different property defaults (false/0) than the defaults in the MyStruct2 definition (true/6). This is because:
Received via email:
JSON Schema "default" keyword reference: https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.2
Example 1
The generated schema for
MyStruct
should be:Note that we set
default
on the properties, not on the top-level schema forMyStruct
.Example 2
It gets more complicated when we use
#[serde(default)]
on fields as well as the struct, e.g.The generated schema for
MyStruct2
should be:Example 3
Note that the default for the
my_struct2
property has different property defaults (false/0) than the defaults in theMyStruct2
definition (true/6). This is because:{}
toMyStruct
results inMyStruct { my_int: 0, my_bool: false, my_struct2: MyStruct2 { my_int: 0, my_bool: false } }
{"my_struct2": {}}
results inMyStruct { my_int: 0, my_bool: false, my_struct2: MyStruct2 { my_int: 6, my_bool: true } }
The text was updated successfully, but these errors were encountered: