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
This makes it tedious/verbose to access these field values, as you either need to check for Some(value) or make liberal use of unwrap().
The code generator does the Option wrapping because the OpenAPI spec does not mark these fields as "mandatory", even though many of them will always be present. For example, in the definition above it is safe to assume that every WikiPage will have an id field.
The current code generator does have the ability to remove the Option wrapper for specific struct fields that are known to always be present (see patch_definition_required_fields()). I have done this by trial and error for a small number of structs that I care about. This must be done with care because if a response does not contain a field that is always expected (not an Option), then the deserialization fails.
If you have specific structs that have Options that you think could be removed then add a comment to this issue and I'll look into fixing.
The text was updated successfully, but these errors were encountered:
Most returned struct fields are wrapped in
Option
.Example:
This makes it tedious/verbose to access these field values, as you either need to check for
Some(value)
or make liberal use ofunwrap()
.The code generator does the
Option
wrapping because the OpenAPI spec does not mark these fields as "mandatory", even though many of them will always be present. For example, in the definition above it is safe to assume that everyWikiPage
will have anid
field.The current code generator does have the ability to remove the
Option
wrapper for specific struct fields that are known to always be present (see patch_definition_required_fields()). I have done this by trial and error for a small number of structs that I care about. This must be done with care because if a response does not contain a field that is always expected (not anOption
), then the deserialization fails.If you have specific structs that have
Options
that you think could be removed then add a comment to this issue and I'll look into fixing.The text was updated successfully, but these errors were encountered: