-
-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Description
here's a test case
#[test]
fn test() {
use serde_with::*;
use std::collections::BTreeSet;
#[serde_as]
#[derive(schemars::JsonSchema)]
struct MyStruct {
#[serde_as(as = "SetPreventDuplicates<DisplayFromStr>")]
via_display_from_str: BTreeSet<u32>, // incorrect schema
#[serde_as(as = "SetPreventDuplicates<Same>")]
via_same: BTreeSet<u32>, // correct schema
}
let schema = format!("{:#}", schemars::schema_for!(MyStruct).as_value());
expect_test::expect![[r#"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"via_display_from_str": {
"type": "string"
},
"via_same": {
"items": {
"format": "uint32",
"minimum": 0,
"type": "integer"
},
"type": "array",
"uniqueItems": true
}
},
"required": [
"via_display_from_str",
"via_same"
],
"title": "MyStruct",
"type": "object"
}"#]]
.assert_eq(&schema);
}Metadata
Metadata
Assignees
Labels
No labels