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:
parent
667009bd22
commit
43d3a1cd89
8 changed files with 159 additions and 35 deletions
|
@ -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"]
|
||||
});
|
||||
|
|
6
openapi_type/tests/fail/enum_with_no_variants.rs
Normal file
6
openapi_type/tests/fail/enum_with_no_variants.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
use openapi_type::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
enum Foo {}
|
||||
|
||||
fn main() {}
|
5
openapi_type/tests/fail/enum_with_no_variants.stderr
Normal file
5
openapi_type/tests/fail/enum_with_no_variants.stderr
Normal 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 {}
|
||||
| ^^
|
|
@ -1,6 +0,0 @@
|
|||
use openapi_type_derive::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
struct Foo;
|
||||
|
||||
fn main() {}
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue