Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-util-schemas/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 1 addition & 34 deletions crates/cargo-util-schemas/manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find the definition of this boolean in JSON schema spec, but it seems to accept anything so indeed fixes the issue. Tested it on https://www.jsonschemavalidator.net/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://json-schema.org/draft/2020-12/json-schema-core#name-boolean-json-schemas

The boolean schema values "true" and "false" are trivial schemas that always produce themselves as assertion results, regardless of the instance value. They never produce annotation results.

"TomlTarget": {
"type": "object",
"properties": {
Expand Down
37 changes: 2 additions & 35 deletions crates/cargo-util-schemas/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use schemars::JsonSchema;

use serde::{Deserialize, Serialize};

use std::collections::HashMap;
use std::string::String;

use toml::Value as TomlValue;
Expand All @@ -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::<std::string::String>(),
),
("integer".to_string(), gen.subschema_for::<i64>()),
("float".to_string(), gen.subschema_for::<f64>()),
("boolean".to_string(), gen.subschema_for::<bool>()),
(
"datetime".to_string(),
gen.subschema_for::<std::string::String>(),
), // Assuming datetime is represented as a string
(
"array".to_string(),
gen.subschema_for::<Vec<TomlValueWrapper>>(),
),
(
"table".to_string(),
gen.subschema_for::<HashMap<std::string::String, TomlValueWrapper>>(),
),
]
.iter()
.cloned()
.collect(),
..Default::default()
})),
..Default::default()
}
.into()
// HACK: this is both more and less permissive than `TomlValue` but its close
gen.subschema_for::<serde_json::Value>().into()
}
}
Loading