Expand description
Contains the functions and structs required to display the RapiDoc UI.
§Example
use rocket_autodocu::settings::UrlObject;
use rocket_autodocu::rapidoc::{make_rapidoc, RapiDocConfig, GeneralConfig};
fn get_rapi_docs() -> RapiDocConfig {
RapiDocConfig {
general: GeneralConfig {
spec_urls: get_urls(), // this is the only required field
..Default::default()
},
..Default::default()
}
}
fn get_urls() -> Vec<UrlObject> {
vec![
UrlObject::new("Resource", "/my_resource/openapi.json"),
]
}
#[rocket::main]
async fn main() {
rocket::build()
.mount("/rapi-doc", make_rapidoc(&get_rapi_docs()))
.launch()
.await
.unwrap();
}
Structs§
- ApiConfig
- Used to configure api access.
- General
Config - A struct containing information about where and how the
openapi.json
files are served. - Hide
Show Config - Used to configure what features to hide or show.
- Layout
Config - Used to customize the layout of the displayed docs.
- NavConfig
- A struct containing information about where and how the
openapi.json
files are served. - Rapi
DocConfig - A struct containing information about where and how the
openapi.json
files are served. - Slots
Config - Config used to configure the slots. Each slot usually corresponds with one section. Each field can include any HTML tags.
- UiConfig
- A struct containing information about where and how the
openapi.json
files are served.
Enums§
- ApiKey
Location - Determines how you want to send the api-key.
- Default
Schema Tab - The schemas are displayed in two tabs - Model and Example. This option allows you to pick the default tab that you would like to be active.
- Fetch
Credentials - A RequestCredentials dictionary value indicating whether the user agent should send cookies from the other domain in the case of cross-origin requests.
- Font
Size - Used to contol the font size of text in the rapi doc interface.
- Layout
- Layout helps in placement of request/response sections. In column layout, request & response sections are placed one below the other, In row layout they are placed side by side. This attribute is applicable only when the device width is more than 768px and the render-style is ‘view’.
- NavBg
Image Repeat - Used to control the repeating of the background image in the nav bar.
- NavBg
Image Size - Used to control the size of the background image in the nav bar.
- NavItem
Spacing - Controls navigation item spacing
- NavTag
Click - Applies only to focused render-style. It determines the behavior of clicking on a Tag in navigation bar. It can either expand-collapse the tag or take you to the tag’s description page.
- Render
Style - Determines display of api-docs. Currently there are two modes supported. ‘read’ - more suitable for reading and ‘view’ more friendly for quick exploring
- Schema
Hide Read Only - Read-only fields in request schemas is always hidden but are shown in response.
- Schema
Hide Write Only - Read-only fields in request schemas is always hidden but are shown in response.
- Schema
Style - Two different ways to display object-schemas in the responses and request bodies.
- Sort
Endpoints By - Used to control the sorting mechanism of endpoints in the rapi doc interface.
- Theme
- Used to control the theme of the rapi doc interface.
Functions§
- make_
rapidoc - Transform the provided
RapiDocConfig
into a list ofRoute
s that serve the RapiDoc ui.