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

Unexpected Behaviour for #[serde(skip_serializing)] #970

Open
SZenglein opened this issue Jul 9, 2024 · 0 comments
Open

Unexpected Behaviour for #[serde(skip_serializing)] #970

SZenglein opened this issue Jul 9, 2024 · 0 comments

Comments

@SZenglein
Copy link

SZenglein commented Jul 9, 2024

I have the following struct:

#[derive(Deserialize, Serialize, ToSchema, Clone, PartialEq, Eq)]
pub struct Auth {
    pub user: String,
    #[serde(skip_serializing)]
    pub password: Option<String>,
}

The struct is used for authentication to an external service, so the password must be saved in plaintext. However I want to be sure I don't accidentally leak the password to a user request.

Note that the password field does not have a skip_deserializing field. It should still be possible to write the field.

I know there are other solutions for this particular problem, but I was surprised the field was completely missing in the generated code.

Suggested solution:
Fields that are either skipped on deserializing or serializing should be treated as optional fields, while only fields that are always skipped are omitted.

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