From e8f3e5e0f20e559e6c5088f9b386cfa9a14eec52 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 8 Jan 2025 11:26:22 -0600 Subject: [PATCH 1/2] chore(schema): Bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/cargo-util-schemas/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6294dc8b..3ecf7022d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -505,7 +505,7 @@ dependencies = [ [[package]] name = "cargo-util-schemas" -version = "0.7.2" +version = "0.7.3" dependencies = [ "schemars", "semver", diff --git a/Cargo.toml b/Cargo.toml index 7affde808..fc87a5e77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ cargo-platform = { path = "crates/cargo-platform", version = "0.2.0" } cargo-test-macro = { version = "0.4.0", path = "crates/cargo-test-macro" } cargo-test-support = { version = "0.7.0", path = "crates/cargo-test-support" } cargo-util = { version = "0.2.14", path = "crates/cargo-util" } -cargo-util-schemas = { version = "0.7.0", path = "crates/cargo-util-schemas" } +cargo-util-schemas = { version = "0.7.3", path = "crates/cargo-util-schemas" } cargo_metadata = "0.19.0" clap = "4.5.20" clap_complete = { version = "4.5.35", features = ["unstable-dynamic"] } diff --git a/crates/cargo-util-schemas/Cargo.toml b/crates/cargo-util-schemas/Cargo.toml index 7821ea953..8a3152ff1 100644 --- a/crates/cargo-util-schemas/Cargo.toml +++ b/crates/cargo-util-schemas/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-util-schemas" -version = "0.7.2" +version = "0.7.3" rust-version = "1.83" # MSRV:1 edition.workspace = true license.workspace = true From e48257d3c82357cae004f34b6cd215b7cdd98af0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 8 Jan 2025 10:55:47 -0600 Subject: [PATCH 2/2] fix(schemas): Fix 'metadata' JSON Schema Found this when looking into #15030 --- .../cargo-util-schemas/manifest.schema.json | 35 +----------------- crates/cargo-util-schemas/src/schema.rs | 37 +------------------ 2 files changed, 3 insertions(+), 69 deletions(-) diff --git a/crates/cargo-util-schemas/manifest.schema.json b/crates/cargo-util-schemas/manifest.schema.json index 37f84f4f7..8fe710d5d 100644 --- a/crates/cargo-util-schemas/manifest.schema.json +++ b/crates/cargo-util-schemas/manifest.schema.json @@ -621,40 +621,7 @@ } ] }, - "TomlValue": { - "type": "object", - "properties": { - "string": { - "type": "string" - }, - "integer": { - "type": "integer", - "format": "int64" - }, - "float": { - "type": "number", - "format": "double" - }, - "boolean": { - "type": "boolean" - }, - "datetime": { - "type": "string" - }, - "array": { - "type": "array", - "items": { - "$ref": "#/definitions/TomlValue" - } - }, - "table": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TomlValue" - } - } - } - }, + "TomlValue": true, "TomlTarget": { "type": "object", "properties": { diff --git a/crates/cargo-util-schemas/src/schema.rs b/crates/cargo-util-schemas/src/schema.rs index f9ce16baa..400997d2b 100644 --- a/crates/cargo-util-schemas/src/schema.rs +++ b/crates/cargo-util-schemas/src/schema.rs @@ -2,7 +2,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use std::string::String; use toml::Value as TomlValue; @@ -16,39 +15,7 @@ impl JsonSchema for TomlValueWrapper { } fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - use schemars::schema::*; - - SchemaObject { - instance_type: Some(InstanceType::Object.into()), - object: Some(Box::new(ObjectValidation { - properties: [ - ( - "string".to_string(), - gen.subschema_for::(), - ), - ("integer".to_string(), gen.subschema_for::()), - ("float".to_string(), gen.subschema_for::()), - ("boolean".to_string(), gen.subschema_for::()), - ( - "datetime".to_string(), - gen.subschema_for::(), - ), // Assuming datetime is represented as a string - ( - "array".to_string(), - gen.subschema_for::>(), - ), - ( - "table".to_string(), - gen.subschema_for::>(), - ), - ] - .iter() - .cloned() - .collect(), - ..Default::default() - })), - ..Default::default() - } - .into() + // HACK: this is both more and less permissive than `TomlValue` but its close + gen.subschema_for::().into() } }