pub struct SwaggerUi {
pub title: Cow<'static, str>,
pub keywords: Option<Cow<'static, str>>,
pub description: Option<Cow<'static, str>>,
/* private fields */
}Available on crate feature
swagger-ui only.Expand description
Implements Handler for serving Swagger UI.
Fields§
§title: Cow<'static, str>The title of the html page. The default title is “Swagger UI”.
keywords: Option<Cow<'static, str>>The keywords of the html page.
description: Option<Cow<'static, str>>The description of the html page.
Implementations§
Source§impl SwaggerUi
impl SwaggerUi
Sourcepub fn title(self, title: impl Into<Cow<'static, str>>) -> Self
pub fn title(self, title: impl Into<Cow<'static, str>>) -> Self
Set title of the html page. The default title is “Swagger UI”.
Sourcepub fn keywords(self, keywords: impl Into<Cow<'static, str>>) -> Self
pub fn keywords(self, keywords: impl Into<Cow<'static, str>>) -> Self
Set keywords of the html page.
Sourcepub fn description(self, description: impl Into<Cow<'static, str>>) -> Self
pub fn description(self, description: impl Into<Cow<'static, str>>) -> Self
Set description of the html page.
Sourcepub fn urls(self, urls: Vec<Url<'static>>) -> Self
pub fn urls(self, urls: Vec<Url<'static>>) -> Self
Add multiple Urls to Swagger UI.
Takes one Vec argument containing tuples of Url and OpenApi.
Situations where this comes handy is when there is a need or wish to separate different parts of the api to separate api docs.
§Examples
Expose multiple api docs via Swagger UI.
let swagger = SwaggerUi::new("/swagger-ui/{_:.*}")
.urls(
vec![
(Url::with_primary("api doc 1", "/api-docs/openapi.json", true)),
(Url::new("api doc 2", "/api-docs/openapi2.json"))
]
);Sourcepub fn oauth(self, oauth: Config) -> Self
pub fn oauth(self, oauth: Config) -> Self
Add oauth oauth::Config into SwaggerUi.
Method takes one argument which exposes the oauth::Config to the user.
§Examples
Enable pkce with default client_id.
let swagger = SwaggerUi::new("/swagger-ui/{_:.*}")
.url("/api-docs/openapi.json")
.oauth(oauth::Config::new()
.client_id("client-id")
.scopes(vec![String::from("openid")])
.use_pkce_with_authorization_code_grant(true)
);Trait Implementations§
Source§impl Handler for SwaggerUi
impl Handler for SwaggerUi
Source§fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
_depot: &'life2 mut Depot,
res: &'life3 mut Response,
_ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
_depot: &'life2 mut Depot,
res: &'life3 mut Response,
_ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Handle http request.
Source§fn arc(self) -> ArcHandlerwhere
Self: Sized,
fn arc(self) -> ArcHandlerwhere
Self: Sized,
Wrap to
ArcHandler.Source§fn hoop<H>(self, hoop: H) -> HoopedHandler
fn hoop<H>(self, hoop: H) -> HoopedHandler
Hoop this handler with middleware.
Auto Trait Implementations§
impl Freeze for SwaggerUi
impl RefUnwindSafe for SwaggerUi
impl Send for SwaggerUi
impl Sync for SwaggerUi
impl Unpin for SwaggerUi
impl UnsafeUnpin for SwaggerUi
impl UnwindSafe for SwaggerUi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more