Implement JsonSchema on EnumSet type
This commit is contained in:
parent
515a87a564
commit
d059686da8
9 changed files with 50 additions and 1 deletions
15
schemars/tests/enumset.rs
Normal file
15
schemars/tests/enumset.rs
Normal 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")
|
||||
}
|
18
schemars/tests/expected/enumset.json
Normal file
18
schemars/tests/expected/enumset.json
Normal 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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue