From 88ee9bb02939bc3d65b50caf135cee7f11a7c1ae Mon Sep 17 00:00:00 2001 From: Micah Date: Tue, 8 Oct 2024 11:45:16 -0700 Subject: [PATCH 1/2] Support `$schema` in JSON structures --- src/project.rs | 3 +++ src/snapshot_middleware/json_model.rs | 3 +++ src/snapshot_middleware/meta_file.rs | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/project.rs b/src/project.rs index 43920a9a3..b9573427f 100644 --- a/src/project.rs +++ b/src/project.rs @@ -51,6 +51,9 @@ enum Error { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct Project { + #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] + schema: Option, + /// The name of the top-level instance described by the project. pub name: Option, diff --git a/src/snapshot_middleware/json_model.rs b/src/snapshot_middleware/json_model.rs index 1341db47e..7cd5ae073 100644 --- a/src/snapshot_middleware/json_model.rs +++ b/src/snapshot_middleware/json_model.rs @@ -61,6 +61,9 @@ pub fn snapshot_json_model( #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] struct JsonModel { + #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] + schema: Option, + #[serde(alias = "Name")] name: Option, diff --git a/src/snapshot_middleware/meta_file.rs b/src/snapshot_middleware/meta_file.rs index e1cd62b78..74b592726 100644 --- a/src/snapshot_middleware/meta_file.rs +++ b/src/snapshot_middleware/meta_file.rs @@ -13,6 +13,9 @@ use crate::{resolution::UnresolvedValue, snapshot::InstanceSnapshot, RojoRef}; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AdjacentMetadata { + #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] + schema: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub id: Option, @@ -104,6 +107,9 @@ impl AdjacentMetadata { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct DirectoryMetadata { + #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] + schema: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub id: Option, From d456baddf9c444160c0759e76734b95169719159 Mon Sep 17 00:00:00 2001 From: Micah Date: Tue, 8 Oct 2024 11:57:57 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f453836e8..621a8ae6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Rojo Changelog ## Unreleased Changes +* Support for a `$schema` field in all special JSON files (`.project.json`, `.model.json`, and `.meta.json`) ([#974]) * Projects may now manually link `Ref` properties together using `Attributes`. ([#843]) This has two parts: using `id` or `$id` in JSON files or a `Rojo_Target` attribute, an Instance is given an ID. Then, that ID may be used elsewhere in the project to point to an Instance @@ -85,6 +86,7 @@ [#886]: https://github.com/rojo-rbx/rojo/pull/886 [#911]: https://github.com/rojo-rbx/rojo/pull/911 [#915]: https://github.com/rojo-rbx/rojo/pull/915 +[#974]: https://github.com/rojo-rbx/rojo/pull/974 ## [7.4.3] - August 6th, 2024 * Fixed issue with building binary files introduced in 7.4.2