Fix more instances of JSON schema getting clobbered when attaching references (#15339)

This PR extends the fix from #15336 to more places that had the same
issue.

An `add_references_to_properties` helper function has been added to
handle these cases uniformly.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-27 11:44:40 -04:00 committed by GitHub
parent 8b22f09b6f
commit 1ffb34c5fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 54 deletions

View file

@ -4,12 +4,12 @@ use gpui::{
};
use schemars::{
gen::SchemaGenerator,
schema::{ArrayValidation, InstanceType, RootSchema, Schema, SchemaObject},
schema::{ArrayValidation, InstanceType, RootSchema, SchemaObject},
JsonSchema,
};
use serde_derive::{Deserialize, Serialize};
use serde_json::Value;
use settings::{SettingsJsonSchemaParams, SettingsSources};
use settings::{add_references_to_properties, SettingsJsonSchemaParams, SettingsSources};
use std::path::PathBuf;
use task::Shell;
@ -231,22 +231,14 @@ impl settings::Settings for TerminalSettings {
("FontFamilies".into(), font_family_schema.into()),
("FontFallbacks".into(), font_fallback_schema.into()),
]);
root_schema
.schema
.object
.as_mut()
.unwrap()
.properties
.extend([
(
"font_family".to_owned(),
Schema::new_ref("#/definitions/FontFamilies".into()),
),
(
"font_fallbacks".to_owned(),
Schema::new_ref("#/definitions/FontFallbacks".into()),
),
]);
add_references_to_properties(
&mut root_schema,
&[
("font_family", "#/definitions/FontFamilies"),
("font_fallbacks", "#/definitions/FontFallbacks"),
],
);
root_schema
}