diff --git a/sea-orm-rocket/lib/Cargo.toml b/sea-orm-rocket/lib/Cargo.toml index c2be95086..77f693dd9 100644 --- a/sea-orm-rocket/lib/Cargo.toml +++ b/sea-orm-rocket/lib/Cargo.toml @@ -24,3 +24,7 @@ version = "0.5.0-rc.1" version = "0.5.0-rc.1" default-features = false features = ["json"] + +[dependencies.rocket_okapi] +version = "0.8.0-rc.2" +default-features = false diff --git a/sea-orm-rocket/lib/src/database.rs b/sea-orm-rocket/lib/src/database.rs index 8826b5f95..a16e3bf89 100644 --- a/sea-orm-rocket/lib/src/database.rs +++ b/sea-orm-rocket/lib/src/database.rs @@ -9,6 +9,9 @@ use rocket::{error, info_, Build, Ignite, Phase, Rocket, Sentinel}; use rocket::figment::providers::Serialized; use rocket::yansi::Paint; +use rocket_okapi::request::{OpenApiFromRequest,RequestHeaderInput}; +use rocket_okapi::gen::OpenApiGenerator; + use crate::Pool; /// Derivable trait which ties a database [`Pool`] with a configuration name. @@ -205,6 +208,12 @@ impl<'a, D: Database> Connection<'a, D> { } } +impl <'r, D: Database> OpenApiFromRequest<'r> for Connection<'r, D> { + fn from_request_input(_gen: &mut OpenApiGenerator, _name: String, _required: bool) -> rocket_okapi::Result { + Ok(RequestHeaderInput::None) + } +} + #[rocket::async_trait] impl Fairing for Initializer { fn info(&self) -> Info {