mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-05-09 16:10:42 +00:00
basic structure for openapi_type crate
This commit is contained in:
parent
2251c29d7b
commit
90870e3b6a
9 changed files with 261 additions and 1 deletions
12
openapi_type/tests/fail/generics_not_openapitype.rs
Normal file
12
openapi_type/tests/fail/generics_not_openapitype.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use openapi_type::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
struct Foo<T> {
|
||||
bar: T
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
fn main() {
|
||||
<Foo<Bar>>::schema();
|
||||
}
|
21
openapi_type/tests/fail/generics_not_openapitype.stderr
Normal file
21
openapi_type/tests/fail/generics_not_openapitype.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
error[E0599]: no function or associated item named `schema` found for struct `Foo<Bar>` in the current scope
|
||||
--> $DIR/generics_not_openapitype.rs:11:14
|
||||
|
|
||||
4 | struct Foo<T> {
|
||||
| -------------
|
||||
| |
|
||||
| function or associated item `schema` not found for this
|
||||
| doesn't satisfy `Foo<Bar>: OpenapiType`
|
||||
...
|
||||
8 | struct Bar;
|
||||
| ----------- doesn't satisfy `Bar: OpenapiType`
|
||||
...
|
||||
11 | <Foo<Bar>>::schema();
|
||||
| ^^^^^^ function or associated item not found in `Foo<Bar>`
|
||||
|
|
||||
= note: the method `schema` exists but the following trait bounds were not satisfied:
|
||||
`Bar: OpenapiType`
|
||||
which is required by `Foo<Bar>: OpenapiType`
|
||||
= help: items from traits can only be used if the trait is implemented and in scope
|
||||
= note: the following trait defines an item `schema`, perhaps you need to implement it:
|
||||
candidate #1: `OpenapiType`
|
6
openapi_type/tests/pass/unit_struct.rs
Normal file
6
openapi_type/tests/pass/unit_struct.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
use openapi_type_derive::OpenapiType;
|
||||
|
||||
#[derive(OpenapiType)]
|
||||
struct Foo;
|
||||
|
||||
fn main() {}
|
8
openapi_type/tests/trybuild.rs
Normal file
8
openapi_type/tests/trybuild.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
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