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

Alias ignored when flattening #2188

Open
TheEnbyperor opened this issue Mar 11, 2022 · 3 comments
Open

Alias ignored when flattening #2188

TheEnbyperor opened this issue Mar 11, 2022 · 3 comments
Labels

Comments

@TheEnbyperor
Copy link

Given an enum with a name and an alias, such as below.

#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum PSCNatureOfControls {
    #[serde(
        rename = "{http://xmlgw.companieshouse.gov.uk}NatureOfControls",
        alias = "{http://www.govtalk.gov.uk/CM/envelope}NatureOfControls"
    )]
    NatureOfControls(NatureOfControls),
    #[serde(
        rename = "{http://xmlgw.companieshouse.gov.uk}LLPNatureOfControls",
        alias = "{http://www.govtalk.gov.uk/CM/envelope}LLPNatureOfControls"
    )]
    LLPNatureOfControls(LLPNatureOfControls),
}

Then put in a struct as such, and flattened.

#[derive(Debug, Deserialize)]
pub struct CompanyDataPSCNotification {
    #[serde(flatten)]
    pub nature_of_control: PSCNatureOfControls,
    ...
}

And when an enum value with the alias name is presented to the deserializer, an error such as "no variant of enum PSCNatureOfControls found in flattened data" is given. When the enum variant is changed from alias to rename, it works as expected.

@jplatte
Copy link
Contributor

jplatte commented Mar 18, 2022

Duplicate of #1504.

@Mingun
Copy link
Contributor

Mingun commented May 9, 2023

This was fixed (partially) by #2387, the in-place part is fixed in #2443

@Colerar
Copy link

Colerar commented Sep 5, 2023

This issue has not yet been fully resolved. struct + flatten + alias works as expected, but enum + flatten + alias does not. Just a reminder.

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

No branches or pull requests

5 participants