From 9e2ba857729f4a313aa2e88b193be7bff1a29cba Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Mon, 5 Apr 2021 20:44:01 +0100 Subject: [PATCH] Also implement JsonSchema for BytesMut --- schemars/src/json_schema_impls/bytes.rs | 3 ++- schemars/tests/bytes.rs | 4 ++-- schemars/tests/expected/bytes.json | 29 +++++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/schemars/src/json_schema_impls/bytes.rs b/schemars/src/json_schema_impls/bytes.rs index 2a84cc2..f1a0f29 100644 --- a/schemars/src/json_schema_impls/bytes.rs +++ b/schemars/src/json_schema_impls/bytes.rs @@ -1,6 +1,7 @@ use crate::gen::SchemaGenerator; use crate::schema::*; use crate::JsonSchema; -use bytes::Bytes; +use bytes::{Bytes, BytesMut}; forward_impl!((JsonSchema for Bytes) => Vec); +forward_impl!((JsonSchema for BytesMut) => Vec); diff --git a/schemars/tests/bytes.rs b/schemars/tests/bytes.rs index 69b5612..688ab21 100644 --- a/schemars/tests/bytes.rs +++ b/schemars/tests/bytes.rs @@ -1,8 +1,8 @@ mod util; -use bytes::Bytes; +use bytes::{Bytes, BytesMut}; use util::*; #[test] fn bytes() -> TestResult { - test_default_generated_schema::("bytes") + test_default_generated_schema::<(Bytes, BytesMut)>("bytes") } diff --git a/schemars/tests/expected/bytes.json b/schemars/tests/expected/bytes.json index 294f0ec..5e1f9a5 100644 --- a/schemars/tests/expected/bytes.json +++ b/schemars/tests/expected/bytes.json @@ -1,10 +1,25 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Array_of_uint8", + "title": "Tuple_of_Array_of_uint8_and_Array_of_uint8", "type": "array", - "items": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - } -} + "items": [ + { + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + } + }, + { + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + } + } + ], + "maxItems": 2, + "minItems": 2 +} \ No newline at end of file