Skip to content

Commit

Permalink
feat: support to okapi
Browse files Browse the repository at this point in the history
  • Loading branch information
eum602 committed Sep 25, 2022
1 parent d77cf24 commit 4eb15f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sea-orm-rocket/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions sea-orm-rocket/lib/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<RequestHeaderInput> {
Ok(RequestHeaderInput::None)
}
}

#[rocket::async_trait]
impl<D: Database> Fairing for Initializer<D> {
fn info(&self) -> Info {
Expand Down

0 comments on commit 4eb15f5

Please sign in to comment.