Description
Most returned struct fields are wrapped in Option
.
Example:
pub struct WikiPage {
pub wiki_page_create_or_update_parameters: [WikiPageCreateOrUpdateParameters],
pub git_item_path: Option<String>,
pub id: Option<i32>,
pub is_non_conformant: Option<bool>,
pub is_parent_page: Option<bool>,
pub order: Option<i32>,
pub path: Option<String>,
pub remote_url: Option<String>,
pub sub_pages: Vec<WikiPage>,
pub url: Option<String>,
}
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.