oxidecomputer / oxidecomputer/progenitor
Nullable compont generates recursive type
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 136
- Avg merge
- 8h 36m
- Merged PRs (30d)
- 14
Description
The GitHub API spec contains the following component:
"auto-merge": {
"title": "Auto merge",
"description": "The status of auto merging a pull request.",
"type": "object",
"properties": {
"enabled_by": {
"$ref": "#/components/schemas/simple-user"
},
"merge_method": {
"type": "string",
"description": "The merge method to use.",
"enum": [
"merge",
"squash",
"rebase"
]
},
"commit_title": {
"type": "string",
"description": "Title for the merge commit message."
},
"commit_message": {
"type": "string",
"description": "Commit message for the merge commit."
}
},
"required": [
"enabled_by",
"merge_method",
"commit_title",
"commit_message"
],
"nullable": true
}
When set as nullable: true this component generates duplicate structs, one of which is recursive:
#[doc = "The status of auto merging a pull request."]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AutoMerge(pub Option<AutoMerge>);
#[doc = "The status of auto merging a pull request."]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AutoMerge {
#[doc = "Commit message for the merge commit."]
pub commit_message: String,
#[doc = "Title for the merge commit message."]
pub commit_title: String,
pub enabled_by: SimpleUser,
#[doc = "The merge method to use."]
pub merge_method: AutoMergeMergeMethod,
}
I haven't tracked down where this occurring, but it looks like:
nullabletriggers two structs to be created, one inner struct containing the fields and one newtype wrapper.- If the component contains a title property, it does not get checked for uniqueness against the wrapper type, and does not have the
Innersuffix added
As a test, if the component is changed to:
"auto-merge": {
"title": "Auto merge test",
...
"nullable": true
}
then it generates:
pub struct AutoMerge(pub Option<AutoMergeTest>);
and removing the tile property generates:
pub struct AutoMerge(pub Option<AutoMergeInner>);
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 by tracing how nullable components are handled during Rust type generation, focusing on wrapper and inner-type naming and uniqueness checks. Use the GitHub API auto-merge component from the issue as a reproduction; it is done when nullable components generate distinct wrapper and inner structs without recursive duplicate definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100