Implement JsonSchema on EnumSet type

This commit is contained in:
Matt Campbell 2021-07-18 18:45:25 -05:00 committed by Graham Esau
parent 515a87a564
commit d059686da8
9 changed files with 50 additions and 1 deletions

15
schemars/tests/enumset.rs Normal file
View file

@ -0,0 +1,15 @@
mod util;
use enumset::{EnumSet, EnumSetType};
use schemars::JsonSchema;
use util::*;
#[derive(EnumSetType, JsonSchema)]
enum Foo {
Bar,
Baz,
}
#[test]
fn enumset() -> TestResult {
test_default_generated_schema::<EnumSet<Foo>>("enumset")
}

View file

@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Set_of_Foo",
"type": "array",
"items": {
"$ref": "#/definitions/Foo"
},
"uniqueItems": true,
"definitions": {
"Foo": {
"type": "string",
"enum": [
"Bar",
"Baz"
]
}
}
}