1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-05-09 16:10:42 +00:00

start implementing enums

This commit is contained in:
Dominic 2021-03-08 17:20:41 +01:00
parent 667009bd22
commit 43d3a1cd89
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
8 changed files with 159 additions and 35 deletions

View file

@ -42,3 +42,38 @@ test_type!(SimpleStruct = {
},
"required": ["foo", "bar"]
});
#[derive(OpenapiType)]
enum EnumWithoutFields {
Success,
Error
}
test_type!(EnumWithoutFields = {
"type": "string",
"title": "EnumWithoutFields",
"enum": [
"Success",
"Error"
]
});
#[derive(OpenapiType)]
enum EnumWithOneField {
Success { value: isize }
}
test_type!(EnumWithOneField = {
"type": "object",
"title": "EnumWithOneField",
"properties": {
"Success": {
"type": "object",
"properties": {
"value": {
"type": "integer"
}
},
"required": ["value"]
}
},
"required": ["Success"]
});

View file

@ -0,0 +1,6 @@
use openapi_type::OpenapiType;
#[derive(OpenapiType)]
enum Foo {}
fn main() {}

View file

@ -0,0 +1,5 @@
error: #[derive(OpenapiType)] does not support enums with no variants
--> $DIR/enum_with_no_variants.rs:4:10
|
4 | enum Foo {}
| ^^

View file

@ -1,6 +0,0 @@
use openapi_type_derive::OpenapiType;
#[derive(OpenapiType)]
struct Foo;
fn main() {}

View file

@ -3,6 +3,5 @@ use trybuild::TestCases;
#[test]
fn trybuild() {
let t = TestCases::new();
t.pass("tests/pass/*.rs");
t.compile_fail("tests/fail/*.rs");
}