diff --git a/serde_with/src/schemars_0_8.rs b/serde_with/src/schemars_0_8.rs index 1696bd80..e7e1fcb5 100644 --- a/serde_with/src/schemars_0_8.rs +++ b/serde_with/src/schemars_0_8.rs @@ -794,9 +794,9 @@ map_first_last_wins_schema!(=> S indexmap_1::IndexMap); #[cfg(feature = "indexmap_2")] map_first_last_wins_schema!(=> S indexmap_2::IndexMap); -impl JsonSchema for WrapSchema, OneOrMany> +impl JsonSchemaAs> for OneOrMany where - WrapSchema: JsonSchema, + TA: JsonSchemaAs, { fn schema_name() -> String { std::format!( @@ -835,9 +835,9 @@ where } } -impl JsonSchema for WrapSchema, OneOrMany> +impl JsonSchemaAs> for OneOrMany where - WrapSchema: JsonSchema, + TA: JsonSchemaAs, { fn schema_name() -> String { std::format!( diff --git a/serde_with/tests/schemars_0_8.rs b/serde_with/tests/schemars_0_8.rs index 2c909c65..4237aa4b 100644 --- a/serde_with/tests/schemars_0_8.rs +++ b/serde_with/tests/schemars_0_8.rs @@ -406,6 +406,13 @@ mod snapshots { value: u32 } } + + one_or_many_nested { + struct Test { + #[serde_as(as = "Option>")] + optional_many: Option>, + } + } } } diff --git a/serde_with/tests/schemars_0_8/snapshots/one_or_many_nested.json b/serde_with/tests/schemars_0_8/snapshots/one_or_many_nested.json new file mode 100644 index 00000000..67c4ce91 --- /dev/null +++ b/serde_with/tests/schemars_0_8/snapshots/one_or_many_nested.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Test", + "type": "object", + "properties": { + "optional_many": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/OneOrMany" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "OneOrMany": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } +}