oxidecomputer / oxidecomputer/typify
Types with explicit defaults on required fields do not implement Default
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 898
- Forks
- 114
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 14
Description
MRE:
Schema:
{
"definitions": {
"Field": {
"type": "object",
"properties": {
"addr": {
"type": "string",
"default": "default_string"
}
},
"required": [
"addr"
]
}
}
}
Generates:
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Field {
pub addr: ::std::string::String,
}
impl ::std::convert::From<&Field> for Field {
fn from(value: &Field) -> Self {
value.clone()
}
}
However, there should be another impl on Field:
impl Default for Field {
fn default() -> Self {
Self {
addr: "default_string".to_string(),
}
}
}
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 reproducing the provided JSON Schema example and inspecting the generated Rust Field output. Trace how explicit defaults on required properties are handled, then verify that the generated type includes a Default implementation returning addr as "default_string".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100