Skip to content

Commit

Permalink
enforce deny_unknown_fields on json1 deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
blmaier committed Mar 6, 2024
1 parent cfd78a3 commit 126eef0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use std::path::{Path, PathBuf};
use std::process::Command;

#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
enum ShellcheckJson1InsertionPoint {
AfterEnd,
BeforeStart,
}

#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
struct ShellcheckJson1Replacement {
line: u32,
end_line: u32,
Expand All @@ -23,12 +23,13 @@ struct ShellcheckJson1Replacement {
}

#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
struct ShellcheckJson1Fix {
replacements: Vec<ShellcheckJson1Replacement>,
}

#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(deny_unknown_fields, rename_all = "lowercase")]
enum ShellcheckJson1Level {
Info,
Warning,
Expand All @@ -37,7 +38,7 @@ enum ShellcheckJson1Level {
}

#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
struct ShellcheckJson1Comment {
file: String,
line: u32,
Expand All @@ -51,6 +52,7 @@ struct ShellcheckJson1Comment {
}

#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
struct ShellcheckJson1 {
comments: Vec<ShellcheckJson1Comment>,
}
Expand Down

0 comments on commit 126eef0

Please sign in to comment.