Struct hypers_openapi::SwaggerUi
source · pub struct SwaggerUi {
pub config: Config<'static>,
pub title: Cow<'static, str>,
pub keywords: Option<Cow<'static, str>>,
pub description: Option<Cow<'static, str>>,
}Expand description
Implements [Handler] for serving Swagger UI.
Fields§
§config: Config<'static>§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: OauthConfig) -> Self
pub fn oauth(self, oauth: OauthConfig) -> 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(OauthConfig::new()
.client_id("client-id")
.scopes(vec![String::from("openid")])
.use_pkce_with_authorization_code_grant(true)
);pub fn serve<'a>( path: &str, title: &str, keywords: &str, description: &str, config: &Config<'a>, ) -> Result<Option<SwaggerFile<'a>>, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwaggerUi
impl RefUnwindSafe for SwaggerUi
impl Send for SwaggerUi
impl Sync for SwaggerUi
impl Unpin 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)