Add test that JSON schema generation works + actions build from no input (#23049)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-13 13:42:08 -07:00 committed by GitHub
parent 85b727c1a2
commit b633f62aa6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 81 additions and 16 deletions

View file

@ -3,7 +3,7 @@ use anyhow::{anyhow, Context, Result};
use collections::{BTreeMap, HashMap};
use gpui::{Action, AppContext, KeyBinding, SharedString};
use schemars::{
gen::SchemaGenerator,
gen::{SchemaGenerator, SchemaSettings},
schema::{ArrayValidation, InstanceType, Metadata, Schema, SchemaObject, SubschemaValidation},
JsonSchema,
};
@ -139,7 +139,17 @@ impl KeymapFile {
Ok(())
}
pub fn generate_json_schema(
pub fn generate_json_schema_for_registered_actions(cx: &mut AppContext) -> Value {
let mut generator = SchemaSettings::draft07()
.with(|settings| settings.option_add_null_type = false)
.into_generator();
let action_schemas = cx.action_schemas(&mut generator);
let deprecations = cx.action_deprecations();
KeymapFile::generate_json_schema(generator, action_schemas, deprecations)
}
fn generate_json_schema(
generator: SchemaGenerator,
action_schemas: Vec<(SharedString, Option<Schema>)>,
deprecations: &HashMap<SharedString, SharedString>,