Deny unknown keys in settings in JSON schema so user gets warnings but settings still parses (#30583)
Closes #ISSUE Release Notes: - Improved checking of Zed settings so that unrecognized keys show warnings while editing them
This commit is contained in:
parent
986d271ea7
commit
ab455e1c43
7 changed files with 18 additions and 2 deletions
|
@ -1966,7 +1966,8 @@ mod tests {
|
|||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
struct UserSettingsJson {
|
||||
#[schemars(deny_unknown_fields)]
|
||||
struct UserSettingsContent {
|
||||
name: Option<String>,
|
||||
age: Option<u32>,
|
||||
staff: Option<bool>,
|
||||
|
@ -1974,7 +1975,7 @@ mod tests {
|
|||
|
||||
impl Settings for UserSettings {
|
||||
const KEY: Option<&'static str> = Some("user");
|
||||
type FileContent = UserSettingsJson;
|
||||
type FileContent = UserSettingsContent;
|
||||
|
||||
fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> Result<Self> {
|
||||
sources.json_merge()
|
||||
|
@ -2008,6 +2009,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
struct MultiKeySettingsJson {
|
||||
key1: Option<String>,
|
||||
key2: Option<String>,
|
||||
|
@ -2046,6 +2048,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
struct JournalSettingsJson {
|
||||
pub path: Option<String>,
|
||||
pub hour_format: Option<HourFormat>,
|
||||
|
@ -2076,6 +2079,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
struct LanguageSettingEntry {
|
||||
language_setting_1: Option<bool>,
|
||||
language_setting_2: Option<bool>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue