From e25791dddf396ce463f542bdee6a7b3f877dea74 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Fri, 27 Dec 2019 16:25:50 +0000 Subject: [PATCH] Add generic type to remote derive example --- docs/_includes/examples/remote_derive.rs | 3 +++ docs/_includes/examples/remote_derive.schema.json | 7 +++++++ schemars/examples/remote_derive.rs | 3 +++ schemars/examples/remote_derive.schema.json | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/docs/_includes/examples/remote_derive.rs b/docs/_includes/examples/remote_derive.rs index a97db01..d67a433 100644 --- a/docs/_includes/examples/remote_derive.rs +++ b/docs/_includes/examples/remote_derive.rs @@ -31,6 +31,9 @@ pub struct Process { pub command_line: String, #[serde(with = "DurationDef")] pub wall_time: Duration, + // Generic types must be explicitly specified with turbofix `::<>` syntax. + #[serde(with = "Vec::")] + pub durations: Vec, } fn main() { diff --git a/docs/_includes/examples/remote_derive.schema.json b/docs/_includes/examples/remote_derive.schema.json index cd4934b..e584177 100644 --- a/docs/_includes/examples/remote_derive.schema.json +++ b/docs/_includes/examples/remote_derive.schema.json @@ -4,12 +4,19 @@ "type": "object", "required": [ "command_line", + "durations", "wall_time" ], "properties": { "command_line": { "type": "string" }, + "durations": { + "type": "array", + "items": { + "$ref": "#/definitions/Duration" + } + }, "wall_time": { "$ref": "#/definitions/Duration" } diff --git a/schemars/examples/remote_derive.rs b/schemars/examples/remote_derive.rs index a97db01..d67a433 100644 --- a/schemars/examples/remote_derive.rs +++ b/schemars/examples/remote_derive.rs @@ -31,6 +31,9 @@ pub struct Process { pub command_line: String, #[serde(with = "DurationDef")] pub wall_time: Duration, + // Generic types must be explicitly specified with turbofix `::<>` syntax. + #[serde(with = "Vec::")] + pub durations: Vec, } fn main() { diff --git a/schemars/examples/remote_derive.schema.json b/schemars/examples/remote_derive.schema.json index cd4934b..e584177 100644 --- a/schemars/examples/remote_derive.schema.json +++ b/schemars/examples/remote_derive.schema.json @@ -4,12 +4,19 @@ "type": "object", "required": [ "command_line", + "durations", "wall_time" ], "properties": { "command_line": { "type": "string" }, + "durations": { + "type": "array", + "items": { + "$ref": "#/definitions/Duration" + } + }, "wall_time": { "$ref": "#/definitions/Duration" }