1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-04-20 06:54:46 +00:00

introduce openapitype

This commit is contained in:
Dominic 2019-09-30 20:58:15 +02:00
parent 24f8fd96db
commit 681482ece3
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
6 changed files with 126 additions and 6 deletions

View file

@ -2,13 +2,18 @@
#[macro_use] extern crate serde;
pub use hyper::StatusCode;
#[cfg(not(feature = "openapi"))]
use serde::Serialize;
pub mod helper;
#[cfg(feature = "openapi")]
pub mod openapi;
#[cfg(feature = "openapi")]
pub use openapi::{GetOpenapi, OpenapiRouter};
pub use openapi::{
router::{GetOpenapi, OpenapiRouter},
types::OpenapiType
};
mod resource;
pub use resource::{
@ -29,3 +34,30 @@ mod routing;
pub use routing::{DrawResources, DrawResourceRoutes};
#[cfg(feature = "openapi")]
pub use routing::WithOpenapi;
/// A type that can be used inside a request or response body. Implemented for every type
/// that is serializable with serde, however, it is recommended to use the rest_struct!
/// macro to create one.
#[cfg(not(feature = "openapi"))]
pub trait ResourceType : Serialize
{
}
#[cfg(not(feature = "openapi"))]
impl<T : Serialize> ResourceType for T
{
}
/// A type that can be used inside a request or response body. Implemented for every type
/// that is serializable with serde, however, it is recommended to use the rest_struct!
/// macro to create one.
#[cfg(feature = "openapi")]
pub trait ResourceType : OpenapiType
{
}
#[cfg(feature = "openapi")]
impl<T : OpenapiType> ResourceType for T
{
}