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:
Ben Kunkle 2025-05-12 17:48:36 -04:00 committed by GitHub
parent 986d271ea7
commit ab455e1c43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 18 additions and 2 deletions

View file

@ -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>,