Skip to content

Commit e48257d

Browse files
committed
fix(schemas): Fix 'metadata' JSON Schema
Found this when looking into #15030
1 parent e8f3e5e commit e48257d

File tree

2 files changed

+3
-69
lines changed

2 files changed

+3
-69
lines changed

crates/cargo-util-schemas/manifest.schema.json

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -621,40 +621,7 @@
621621
}
622622
]
623623
},
624-
"TomlValue": {
625-
"type": "object",
626-
"properties": {
627-
"string": {
628-
"type": "string"
629-
},
630-
"integer": {
631-
"type": "integer",
632-
"format": "int64"
633-
},
634-
"float": {
635-
"type": "number",
636-
"format": "double"
637-
},
638-
"boolean": {
639-
"type": "boolean"
640-
},
641-
"datetime": {
642-
"type": "string"
643-
},
644-
"array": {
645-
"type": "array",
646-
"items": {
647-
"$ref": "#/definitions/TomlValue"
648-
}
649-
},
650-
"table": {
651-
"type": "object",
652-
"additionalProperties": {
653-
"$ref": "#/definitions/TomlValue"
654-
}
655-
}
656-
}
657-
},
624+
"TomlValue": true,
658625
"TomlTarget": {
659626
"type": "object",
660627
"properties": {

crates/cargo-util-schemas/src/schema.rs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use schemars::JsonSchema;
22

33
use serde::{Deserialize, Serialize};
44

5-
use std::collections::HashMap;
65
use std::string::String;
76

87
use toml::Value as TomlValue;
@@ -16,39 +15,7 @@ impl JsonSchema for TomlValueWrapper {
1615
}
1716

1817
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
19-
use schemars::schema::*;
20-
21-
SchemaObject {
22-
instance_type: Some(InstanceType::Object.into()),
23-
object: Some(Box::new(ObjectValidation {
24-
properties: [
25-
(
26-
"string".to_string(),
27-
gen.subschema_for::<std::string::String>(),
28-
),
29-
("integer".to_string(), gen.subschema_for::<i64>()),
30-
("float".to_string(), gen.subschema_for::<f64>()),
31-
("boolean".to_string(), gen.subschema_for::<bool>()),
32-
(
33-
"datetime".to_string(),
34-
gen.subschema_for::<std::string::String>(),
35-
), // Assuming datetime is represented as a string
36-
(
37-
"array".to_string(),
38-
gen.subschema_for::<Vec<TomlValueWrapper>>(),
39-
),
40-
(
41-
"table".to_string(),
42-
gen.subschema_for::<HashMap<std::string::String, TomlValueWrapper>>(),
43-
),
44-
]
45-
.iter()
46-
.cloned()
47-
.collect(),
48-
..Default::default()
49-
})),
50-
..Default::default()
51-
}
52-
.into()
18+
// HACK: this is both more and less permissive than `TomlValue` but its close
19+
gen.subschema_for::<serde_json::Value>().into()
5320
}
5421
}

0 commit comments

Comments
 (0)