mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-22 12:42:28 +00:00
more error messages
[skip ci]
This commit is contained in:
parent
a57f1c097d
commit
2a35e044db
9 changed files with 62 additions and 2 deletions
6
openapi_type/tests/fail/tuple_struct.rs
Normal file
6
openapi_type/tests/fail/tuple_struct.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
use openapi_type::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
struct Foo(i64, i64);
|
||||
|
||||
fn main() {}
|
5
openapi_type/tests/fail/tuple_struct.stderr
Normal file
5
openapi_type/tests/fail/tuple_struct.stderr
Normal file
|
@ -0,0 +1,5 @@
|
|||
error: #[derive(OpenapiType)] does not support tuple structs
|
||||
--> $DIR/tuple_struct.rs:4:11
|
||||
|
|
||||
4 | struct Foo(i64, i64);
|
||||
| ^^^^^^^^^^
|
8
openapi_type/tests/fail/tuple_variant.rs
Normal file
8
openapi_type/tests/fail/tuple_variant.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use openapi_type::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
enum Foo {
|
||||
Pair(i64, i64)
|
||||
}
|
||||
|
||||
fn main() {}
|
5
openapi_type/tests/fail/tuple_variant.stderr
Normal file
5
openapi_type/tests/fail/tuple_variant.stderr
Normal file
|
@ -0,0 +1,5 @@
|
|||
error: #[derive(OpenapiType)] does not support tuple variants
|
||||
--> $DIR/tuple_variant.rs:5:6
|
||||
|
|
||||
5 | Pair(i64, i64)
|
||||
| ^^^^^^^^^^
|
9
openapi_type/tests/fail/union.rs
Normal file
9
openapi_type/tests/fail/union.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use openapi_type::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
union Foo {
|
||||
signed: i64,
|
||||
unsigned: u64
|
||||
}
|
||||
|
||||
fn main() {}
|
5
openapi_type/tests/fail/union.stderr
Normal file
5
openapi_type/tests/fail/union.stderr
Normal file
|
@ -0,0 +1,5 @@
|
|||
error: #[derive(OpenapiType)] cannot be used on unions
|
||||
--> $DIR/union.rs:4:1
|
||||
|
|
||||
4 | union Foo {
|
||||
| ^^^^^
|
7
openapi_type/tests/fail/unknown_attribute.rs
Normal file
7
openapi_type/tests/fail/unknown_attribute.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use openapi_type::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
#[openapi(pizza)]
|
||||
struct Foo;
|
||||
|
||||
fn main() {}
|
5
openapi_type/tests/fail/unknown_attribute.stderr
Normal file
5
openapi_type/tests/fail/unknown_attribute.stderr
Normal file
|
@ -0,0 +1,5 @@
|
|||
error: Unexpected token
|
||||
--> $DIR/unknown_attribute.rs:4:11
|
||||
|
|
||||
4 | #[openapi(pizza)]
|
||||
| ^^^^^
|
|
@ -35,7 +35,12 @@ fn parse_named_fields(named_fields: &FieldsNamed) -> syn::Result<ParseData> {
|
|||
pub(super) fn parse_struct(strukt: &DataStruct) -> syn::Result<ParseData> {
|
||||
match &strukt.fields {
|
||||
Fields::Named(named_fields) => parse_named_fields(named_fields),
|
||||
Fields::Unnamed(_) => unimplemented!(),
|
||||
Fields::Unnamed(unnamed_fields) => {
|
||||
return Err(syn::Error::new(
|
||||
unnamed_fields.span(),
|
||||
"#[derive(OpenapiType)] does not support tuple structs"
|
||||
))
|
||||
},
|
||||
Fields::Unit => Ok(ParseData::Unit)
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +55,12 @@ pub(super) fn parse_enum(inum: &DataEnum, attrs: &ContainerAttributes) -> syn::R
|
|||
Fields::Named(named_fields) => {
|
||||
types.push((name, parse_named_fields(named_fields)?));
|
||||
},
|
||||
Fields::Unnamed(_unnamed_fields) => unimplemented!(),
|
||||
Fields::Unnamed(unnamed_fields) => {
|
||||
return Err(syn::Error::new(
|
||||
unnamed_fields.span(),
|
||||
"#[derive(OpenapiType)] does not support tuple variants"
|
||||
))
|
||||
},
|
||||
Fields::Unit => strings.push(name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue