From ddb07a709129b24ed8e106b0fbf576b6ded615ac Mon Sep 17 00:00:00 2001 From: ralpha Date: Wed, 15 Jun 2022 09:42:53 +0200 Subject: [PATCH] Add docs for `rocket_db_pools` feature flag Cleanup and docs after merging of #104 --- README.md | 1 + rocket-okapi/CHANGELOG.md | 3 +++ rocket-okapi/src/request/from_request_impls.rs | 17 ++++++++++------- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index efdc3437..6b9f2d04 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Rocket-Okapi: - `mtls`: Enable [mutual TSL for Rocket](https://rocket.rs/v0.5-rc/guide/configuration/#mutual-tls). (when same Rocket feature flag is used.) - `rocket_dyn_templates`: Enable compatibility with [`rocket_dyn_templates`](https://crates.io/crates/rocket_dyn_templates). +- `rocket_db_pools`: Enable compatibility with [`rocket_db_pools`](https://crates.io/crates/rocket_db_pools). Note that not all feature flags from [`Schemars`][Schemars] are re-exported or enabled. So if you have objects for which the `JsonSchema` trait is not implemented, diff --git a/rocket-okapi/CHANGELOG.md b/rocket-okapi/CHANGELOG.md index 4168a97f..2753d886 100644 --- a/rocket-okapi/CHANGELOG.md +++ b/rocket-okapi/CHANGELOG.md @@ -43,8 +43,11 @@ because of incompatibility. - `rocket::http::uri::Host` - `Certificate` (when `mtls` feature is enabled) - `FlashMessage` + - `rocket_db_pools::Connection` (when `rocket_db_pools` feature is enabled) (#104) - New feature flag `rocket_dyn_templates` for enable compatibility with [`rocket_dyn_templates`](https://crates.io/crates/rocket_dyn_templates). +- New feature flag `rocket_db_pools` for enable compatibility with +[`rocket_db_pools`](https://crates.io/crates/rocket_db_pools). - New example for Rocket's Dynamic Templates. ### Changed diff --git a/rocket-okapi/src/request/from_request_impls.rs b/rocket-okapi/src/request/from_request_impls.rs index f7f1fea7..99bfd783 100644 --- a/rocket-okapi/src/request/from_request_impls.rs +++ b/rocket-okapi/src/request/from_request_impls.rs @@ -162,13 +162,6 @@ impl<'r, T: Send + Sync + 'static> OpenApiFromRequest<'r> for &'r rocket::State< } } -#[cfg(feature = "rocket_db_pools")] -impl<'r, T: rocket_db_pools::Database> OpenApiFromRequest<'r> for rocket_db_pools::Connection { - fn from_request_input(_gen: &mut OpenApiGenerator, _name: String, _required: bool) -> Result { - Ok(RequestHeaderInput::None) - } -} - impl<'r, T: OpenApiFromRequest<'r>> OpenApiFromRequest<'r> for Option { fn from_request_input(gen: &mut OpenApiGenerator, name: String, _required: bool) -> Result { T::from_request_input(gen, name, false) @@ -180,3 +173,13 @@ impl<'r, T: OpenApiFromRequest<'r>> OpenApiFromRequest<'r> for StdResult OpenApiFromRequest<'r> for rocket_db_pools::Connection { + fn from_request_input(_gen: &mut OpenApiGenerator, _name: String, _required: bool) -> Result { + Ok(RequestHeaderInput::None) + } +}