Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Rust code overrides Option keyword when array key is options #2521

Open
ASTRELION opened this issue Feb 25, 2024 · 0 comments
Open

Comments

@ASTRELION
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant