oxidecomputer / oxidecomputer/typify
Use serde deserialization instead of constructor for defaults
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 898
- Forks
- 114
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 14
Description
For the following schema:
"field": {
"allOf": [
{
"$ref": "#/components/schemas/MyStruct"
}
],
"default": "0",
},
The part of generated code is:
...
pub mod defaults {
pub(super) fn object_field() -> super::MyStruct {
super::MyStruct("0".to_string())
}
}
...
It can be, there is no constructor for MyStruct which accepts string.
So it's better to use serde deserialization rather than using constructor
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 schema shown in the issue and inspect the generated defaults module for the allOf reference. Verify that the generated default compiles and deserializes the value for MyStruct rather than calling a constructor.
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
- 35/100