diff --git a/schemars/tests/enum.rs b/schemars/tests/enum.rs index 420629c..010419a 100644 --- a/schemars/tests/enum.rs +++ b/schemars/tests/enum.rs @@ -7,8 +7,9 @@ use util::*; pub enum External { UnitOne, StringMap(Map), - Struct{ foo: i32, bar: bool }, + Struct { foo: i32, bar: bool }, UnitTwo, + Tuple(i32, bool), } #[test] @@ -21,7 +22,7 @@ fn enum_external_tag() -> TestResult { pub enum Internal { UnitOne, StringMap(Map), - Struct{ foo: i32, bar: bool }, + Struct { foo: i32, bar: bool }, UnitTwo, } @@ -35,7 +36,8 @@ fn enum_internal_tag() -> TestResult { pub enum Untagged { UnitOne, StringMap(Map), - Struct{ foo: i32, bar: bool } + Struct { foo: i32, bar: bool }, + Tuple(i32, bool), } #[test] diff --git a/schemars/tests/expected/enum-external.json b/schemars/tests/expected/enum-external.json index 4e31de2..4ce574e 100644 --- a/schemars/tests/expected/enum-external.json +++ b/schemars/tests/expected/enum-external.json @@ -44,6 +44,27 @@ "required": [ "struct" ] + }, + { + "type": "object", + "properties": { + "tuple": { + "type": "array", + "items": [ + { + "type": "integer" + }, + { + "type": "boolean" + } + ], + "maxItems": 2, + "minItems": 2 + } + }, + "required": [ + "tuple" + ] } ] } \ No newline at end of file diff --git a/schemars/tests/expected/enum-untagged.json b/schemars/tests/expected/enum-untagged.json index e874634..48cbc47 100644 --- a/schemars/tests/expected/enum-untagged.json +++ b/schemars/tests/expected/enum-untagged.json @@ -25,6 +25,19 @@ "bar", "foo" ] + }, + { + "type": "array", + "items": [ + { + "type": "integer" + }, + { + "type": "boolean" + } + ], + "maxItems": 2, + "minItems": 2 } ] } \ No newline at end of file diff --git a/schemars_derive/src/lib.rs b/schemars_derive/src/lib.rs index d9288dc..b45ddf2 100644 --- a/schemars_derive/src/lib.rs +++ b/schemars_derive/src/lib.rs @@ -105,7 +105,7 @@ fn schema_for_enum(variants: &[Variant], cattrs: &attr::Container) -> TokenStrea EnumTag::External => schema_for_external_tagged_enum(variants, cattrs), EnumTag::None => schema_for_untagged_enum(variants, cattrs), EnumTag::Internal { tag } => schema_for_internal_tagged_enum(variants, cattrs, tag), - _ => unimplemented!("Adjacent/internal tagged enums not yet supported."), + EnumTag::Adjacent => unimplemented!("Adjacent tagged enums not yet supported."), } }