1
0
Fork 0
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:
Dominic 2021-03-07 19:05:25 +01:00
parent 2251c29d7b
commit 90870e3b6a
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
9 changed files with 261 additions and 1 deletions

View file

@ -0,0 +1,12 @@
use openapi_type::OpenapiType;
#[derive(OpenapiType)]
struct Foo<T> {
bar: T
}
struct Bar;
fn main() {
<Foo<Bar>>::schema();
}

View 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`

View file

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

View 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");
}