Generated Rust code overrides `Option` keyword when array key is `options`
ASTRELION opened this issue · comments
ASTRELION commented
Similar to #2385, generated code can still override the built-in Option
type when an array field is named options
in the JSON data (I'm assuming since it makes the word singular and doesn't recognize the keyword).
Example input:
{
"options": [
{
"name": "test"
},
{
"name": "test2",
"foo": "bar"
}
]
}
Output:
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Test {
options: Vec<Option>,
}
#[derive(Serialize, Deserialize)]
pub struct Option {
name: String,
foo: Option<String>,
}
Note the now invalid use of Option<String>