Also implement JsonSchema for BytesMut

This commit is contained in:
Graham Esau 2021-04-05 20:44:01 +01:00
parent 0e3938798f
commit 9e2ba85772
3 changed files with 26 additions and 10 deletions

View file

@ -1,6 +1,7 @@
use crate::gen::SchemaGenerator; use crate::gen::SchemaGenerator;
use crate::schema::*; use crate::schema::*;
use crate::JsonSchema; use crate::JsonSchema;
use bytes::Bytes; use bytes::{Bytes, BytesMut};
forward_impl!((JsonSchema for Bytes) => Vec<u8>); forward_impl!((JsonSchema for Bytes) => Vec<u8>);
forward_impl!((JsonSchema for BytesMut) => Vec<u8>);

View file

@ -1,8 +1,8 @@
mod util; mod util;
use bytes::Bytes; use bytes::{Bytes, BytesMut};
use util::*; use util::*;
#[test] #[test]
fn bytes() -> TestResult { fn bytes() -> TestResult {
test_default_generated_schema::<Bytes>("bytes") test_default_generated_schema::<(Bytes, BytesMut)>("bytes")
} }

View file

@ -1,10 +1,25 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "Array_of_uint8", "title": "Tuple_of_Array_of_uint8_and_Array_of_uint8",
"type": "array", "type": "array",
"items": { "items": [
"type": "integer", {
"format": "uint8", "type": "array",
"minimum": 0.0 "items": {
} "type": "integer",
} "format": "uint8",
"minimum": 0.0
}
},
{
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
}
],
"maxItems": 2,
"minItems": 2
}