Skip to content

Commit

Permalink
Add docs for rocket_db_pools feature flag
Browse files Browse the repository at this point in the history
Cleanup and docs after merging of #104
  • Loading branch information
ralpha committed Jun 15, 2022
1 parent 282d22c commit ddb07a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions rocket-okapi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ because of incompatibility.
- `rocket::http::uri::Host`
- `Certificate` (when `mtls` feature is enabled)
- `FlashMessage`
- `rocket_db_pools::Connection<D>` (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
Expand Down
17 changes: 10 additions & 7 deletions rocket-okapi/src/request/from_request_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
fn from_request_input(_gen: &mut OpenApiGenerator, _name: String, _required: bool) -> Result {
Ok(RequestHeaderInput::None)
}
}

impl<'r, T: OpenApiFromRequest<'r>> OpenApiFromRequest<'r> for Option<T> {
fn from_request_input(gen: &mut OpenApiGenerator, name: String, _required: bool) -> Result {
T::from_request_input(gen, name, false)
Expand All @@ -180,3 +173,13 @@ impl<'r, T: OpenApiFromRequest<'r>> OpenApiFromRequest<'r> for StdResult<T, T::E
T::from_request_input(gen, name, required)
}
}

// ## Implementations for other crates
// https://docs.rs/rocket_db_pools/0.1.0-rc.2/rocket_db_pools/struct.Connection.html#impl-FromRequest%3C%27r%3E

#[cfg(feature = "rocket_db_pools")]
impl<'r, D: rocket_db_pools::Database> OpenApiFromRequest<'r> for rocket_db_pools::Connection<D> {
fn from_request_input(_gen: &mut OpenApiGenerator, _name: String, _required: bool) -> Result {
Ok(RequestHeaderInput::None)
}
}

0 comments on commit ddb07a7

Please sign in to comment.