mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-08-16 11:20:28 +03:00
fix(build): move capability schema definitions to root (#8906)
This commit is contained in:
parent
6f064a0d6f
commit
0e8e9cd064
5
.changes/fix-capability-schema-definitions.md
Normal file
5
.changes/fix-capability-schema-definitions.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-build": patch:bug
|
||||
---
|
||||
|
||||
Fixes the capability schema not resolving inner definitions.
|
@ -86,6 +86,8 @@ fn capabilities_schema(plugin_manifests: &BTreeMap<String, Manifest>) -> RootSch
|
||||
}));
|
||||
}
|
||||
|
||||
let mut definitions = Vec::new();
|
||||
|
||||
if let Some(Schema::Object(obj)) = schema.definitions.get_mut("PermissionEntry") {
|
||||
let permission_entry_any_of_schemas = obj.subschemas().any_of.as_mut().unwrap();
|
||||
|
||||
@ -96,17 +98,20 @@ fn capabilities_schema(plugin_manifests: &BTreeMap<String, Manifest>) -> RootSch
|
||||
|
||||
for (plugin, manifest) in plugin_manifests {
|
||||
if let Some(global_scope_schema) = &manifest.global_scope_schema {
|
||||
let global_scope_schema_def: Schema = serde_json::from_value(global_scope_schema.clone())
|
||||
let global_scope_schema_def: RootSchema =
|
||||
serde_json::from_value(global_scope_schema.clone())
|
||||
.unwrap_or_else(|e| panic!("invalid JSON schema for plugin {plugin}: {e}"));
|
||||
|
||||
let global_scope_schema = Schema::Object(SchemaObject {
|
||||
array: Some(Box::new(ArrayValidation {
|
||||
items: Some(global_scope_schema_def.into()),
|
||||
items: Some(Schema::Object(global_scope_schema_def.schema).into()),
|
||||
..Default::default()
|
||||
})),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
definitions.push(global_scope_schema_def.definitions);
|
||||
|
||||
let mut required = BTreeSet::new();
|
||||
required.insert("identifier".to_string());
|
||||
|
||||
@ -170,6 +175,10 @@ fn capabilities_schema(plugin_manifests: &BTreeMap<String, Manifest>) -> RootSch
|
||||
}
|
||||
}
|
||||
|
||||
for definitions_map in definitions {
|
||||
schema.definitions.extend(definitions_map);
|
||||
}
|
||||
|
||||
schema
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user