microsoft / microsoft/azure-devops-rust-api
Most returned struct fields are wrapped in Option
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 76
- Forks
- 27
- Avg merge
- 9d 20h
- Merged PRs (30d)
- 3
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vsts-api-patcher/src/main.rs and read patch_definition_required_fields(). Identify specific returned structs and fields whose Option wrappers may be removed, then verify that the corresponding responses always contain them. Done means the selected fields are patched safely without causing deserialization failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100