Skip to content

Commit

Permalink
Polis more apis (#49)
Browse files Browse the repository at this point in the history
* Polish security module types
* Polish utoipa-swagger-ui
  • Loading branch information
juhaku authored Mar 28, 2022
1 parent 89ba5a2 commit 7cb08d5
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 314 deletions.
29 changes: 17 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,30 @@ pub trait Path {
/// Add custom JWT [`SecuritySchema`][security_schema] to [`OpenApi`][`openapi::OpenApi`].
/// ```rust
/// # use utoipa::{OpenApi, Modify};
/// # use utoipa::openapi::security::{SecuritySchema, Http, HttpAuthenticationType};
/// # use utoipa::openapi::security::{SecuritySchema, HttpBuilder, HttpAuthScheme};
/// #[derive(OpenApi)]
/// #[openapi(modifiers(&SecurityAddon))]
/// struct ApiDoc;
///
/// struct SecurityAddon;
///
/// impl Modify for SecurityAddon {
/// fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
/// if let Some(components) = openapi.components.as_mut() {
/// components.add_security_schema(
/// "api_jwt_token",
/// SecuritySchema::Http(
/// Http::new(HttpAuthenticationType::Bearer).with_bearer_format("JWT"),
/// ),
/// )
/// }
/// }
///}
/// fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
/// openapi.components = Some(
/// utoipa::openapi::ComponentsBuilder::new()
/// .security_schema(
/// "api_jwt_token",
/// SecuritySchema::Http(
/// HttpBuilder::new()
/// .scheme(HttpAuthScheme::Bearer)
/// .bearer_format("JWT")
/// .build(),
/// ),
/// )
/// .build(),
/// )
/// }
/// }
/// ```
pub trait Modify {
fn modify(&self, openapi: &mut openapi::OpenApi);
Expand Down
2 changes: 1 addition & 1 deletion src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ mod tests {
path::{OperationBuilder, PathsBuilder},
};

use super::{path::Operation, response::Response, *};
use super::{response::Response, *};

#[test]
fn serialize_deserialize_openapi_version_success() -> Result<(), serde_json::Error> {
Expand Down
Loading

0 comments on commit 7cb08d5

Please sign in to comment.