Skip to content

Commit 715cbde

Browse files
authored
feat(config): add $schema to tauri.conf.json, closes #3464 (#4031)
1 parent ec79e07 commit 715cbde

File tree

31 files changed

+173
-70
lines changed

31 files changed

+173
-70
lines changed

.changes/config-$schema.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-utils": patch
3+
"cli.rs": patch
4+
"cli.js": patch
5+
---
6+
7+
Added `$schema` support to `tauri.conf.json`.

core/tauri-utils/src/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,9 @@ impl PackageConfig {
21252125
#[cfg_attr(feature = "schema", derive(JsonSchema))]
21262126
#[serde(rename_all = "camelCase", deny_unknown_fields)]
21272127
pub struct Config {
2128+
/// The JSON schema for the Tauri config.
2129+
#[serde(rename = "$schema")]
2130+
pub schema: Option<String>,
21282131
/// Package settings.
21292132
#[serde(default)]
21302133
pub package: PackageConfig,
@@ -2887,12 +2890,13 @@ mod build {
28872890

28882891
impl ToTokens for Config {
28892892
fn to_tokens(&self, tokens: &mut TokenStream) {
2893+
let schema = quote!(None);
28902894
let package = &self.package;
28912895
let tauri = &self.tauri;
28922896
let build = &self.build;
28932897
let plugins = &self.plugins;
28942898

2895-
literal_struct!(tokens, Config, package, tauri, build, plugins);
2899+
literal_struct!(tokens, Config, schema, package, tauri, build, plugins);
28962900
}
28972901
}
28982902
}

core/tauri/src/test/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub fn noop_assets() -> NoopAsset {
4242
pub fn mock_context<A: Assets>(assets: A) -> crate::Context<A> {
4343
crate::Context {
4444
config: Config {
45+
schema: None,
4546
package: Default::default(),
4647
tauri: TauriConfig {
4748
pattern: PatternKind::Brownfield,

core/tauri/test/fixture/src-tauri/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../../../../tooling/cli/schema.json",
23
"build": {
34
"distDir": "../dist",
45
"devPath": "http://localhost:4000"

core/tests/app-updater/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../../tooling/cli/schema.json",
23
"build": {
34
"distDir": [],
45
"devPath": []

examples/api/src-tauri/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../../tooling/cli/schema.json",
23
"build": {
34
"distDir": "../dist",
45
"devPath": "http://localhost:5000",

examples/commands/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../tooling/cli/schema.json",
23
"build": {
34
"distDir": ["index.html"],
45
"devPath": ["index.html"],

examples/helloworld/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../tooling/cli/schema.json",
23
"build": {
34
"distDir": ["index.html"],
45
"devPath": ["index.html"],

examples/isolation/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../tooling/cli/schema.json",
23
"package": {
34
"productName": "isolation",
45
"version": "0.1.0"

examples/multiwindow/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../tooling/cli/schema.json",
23
"build": {
34
"distDir": ["index.html"],
45
"devPath": ["index.html"],

0 commit comments

Comments
 (0)