Skip to content

Commit 0e8e9cd

Browse files
authored
fix(build): move capability schema definitions to root (#8906)
1 parent 6f064a0 commit 0e8e9cd

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-build": patch:bug
3+
---
4+
5+
Fixes the capability schema not resolving inner definitions.

core/tauri-build/src/acl.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ fn capabilities_schema(plugin_manifests: &BTreeMap<String, Manifest>) -> RootSch
8686
}));
8787
}
8888

89+
let mut definitions = Vec::new();
90+
8991
if let Some(Schema::Object(obj)) = schema.definitions.get_mut("PermissionEntry") {
9092
let permission_entry_any_of_schemas = obj.subschemas().any_of.as_mut().unwrap();
9193

@@ -96,17 +98,20 @@ fn capabilities_schema(plugin_manifests: &BTreeMap<String, Manifest>) -> RootSch
9698

9799
for (plugin, manifest) in plugin_manifests {
98100
if let Some(global_scope_schema) = &manifest.global_scope_schema {
99-
let global_scope_schema_def: Schema = serde_json::from_value(global_scope_schema.clone())
100-
.unwrap_or_else(|e| panic!("invalid JSON schema for plugin {plugin}: {e}"));
101+
let global_scope_schema_def: RootSchema =
102+
serde_json::from_value(global_scope_schema.clone())
103+
.unwrap_or_else(|e| panic!("invalid JSON schema for plugin {plugin}: {e}"));
101104

102105
let global_scope_schema = Schema::Object(SchemaObject {
103106
array: Some(Box::new(ArrayValidation {
104-
items: Some(global_scope_schema_def.into()),
107+
items: Some(Schema::Object(global_scope_schema_def.schema).into()),
105108
..Default::default()
106109
})),
107110
..Default::default()
108111
});
109112

113+
definitions.push(global_scope_schema_def.definitions);
114+
110115
let mut required = BTreeSet::new();
111116
required.insert("identifier".to_string());
112117

@@ -170,6 +175,10 @@ fn capabilities_schema(plugin_manifests: &BTreeMap<String, Manifest>) -> RootSch
170175
}
171176
}
172177

178+
for definitions_map in definitions {
179+
schema.definitions.extend(definitions_map);
180+
}
181+
173182
schema
174183
}
175184

0 commit comments

Comments
 (0)